File tree Expand file tree Collapse file tree 4 files changed +12
-8
lines changed
clients/algoliasearch-client-java-2
generators/src/main/java/com/algolia/codegen
playground/java/src/main/java/com/algolia/playground
templates/java/libraries/okhttp-gson Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ gradle*
19
19
20
20
# Selective source file
21
21
algoliasearch-core/com/algolia/auth/**
22
+ algoliasearch-core/com/algolia/ApiException.java
22
23
algoliasearch-core/com/algolia/Configuration.java
23
24
algoliasearch-core/com/algolia/Server*.java
24
25
algoliasearch-core/com/algolia/StringUtil.java
Original file line number Diff line number Diff line change @@ -168,14 +168,6 @@ public void processOpts() {
168
168
"algoliasearch-core/com/algolia/utils/echo" ,
169
169
"EchoResponse.java" ));
170
170
171
- // remove ApiException.java
172
- for (int i = 0 ; i < supportingFiles .size (); i ++) {
173
- if (supportingFiles .get (i ).getTemplateFile ().equals ("apiException.mustache" )) {
174
- supportingFiles .remove (i );
175
- break ;
176
- }
177
- }
178
-
179
171
// Prevent all useless file to generate
180
172
apiTestTemplateFiles .clear ();
181
173
modelTestTemplateFiles .clear ();
Original file line number Diff line number Diff line change @@ -13,22 +13,29 @@ public static void main(String[] args) {
13
13
Dotenv dotenv = Dotenv .configure ().directory ("../" ).load ();
14
14
15
15
SearchApi client = new SearchApi (dotenv .get ("ALGOLIA_APPLICATION_ID" ), dotenv .get ("ALGOLIA_SEARCH_KEY" ));
16
+
16
17
String indexName = dotenv .get ("SEARCH_INDEX" );
17
18
SearchParamsObject params = new SearchParamsObject ();
18
19
params .setAroundRadius (AroundRadius .ofInteger (5 ));
19
20
params .setQuery (dotenv .get ("SEARCH_QUERY" ));
21
+
20
22
try {
21
23
SearchResponse result = client .search (indexName , SearchParams .ofSearchParamsObject (params ));
22
24
System .out .println (result );
23
25
} catch (AlgoliaApiException e ) {
26
+ // the API failed
24
27
System .err .println ("Exception when calling SearchApi#search" );
25
28
System .err .println ("Status code: " + e .getHttpErrorCode ());
26
29
System .err .println ("Reason: " + e .getMessage ());
27
30
e .printStackTrace ();
31
+
28
32
} catch (AlgoliaRetryException e ) {
33
+ // the retry failed
29
34
System .err .println ("Exception in the retry strategy" );
30
35
e .printStackTrace ();
36
+
31
37
} catch (AlgoliaRuntimeException e ) {
38
+ // the serialization or something else failed
32
39
e .printStackTrace ();
33
40
}
34
41
}
Original file line number Diff line number Diff line change @@ -37,14 +37,18 @@ public class {{classname}} extends ApiClient {
37
37
public { {classname} }(String appId, String apiKey) {
38
38
super(appId, apiKey, new HttpRequester(getDefaultHosts(" ." )));
39
39
}
40
+
40
41
{ {/fallbackToAliasHost} }
41
42
public { {classname} }(String appId, String apiKey, String region) {
42
43
super(appId, apiKey, new HttpRequester(getDefaultHosts(region)));
43
44
}
44
45
{ {/hasRegionalHost} }
46
+
47
+ { {^hasRegionalHost} }
45
48
public { {classname} }(String appId, String apiKey) {
46
49
super(appId, apiKey, new HttpRequester(getDefaultHosts(appId)));
47
50
}
51
+ { {/hasRegionalHost} }
48
52
49
53
public { {classname} }(String appId, String apiKey, Requester requester) {
50
54
super(appId, apiKey, requester);
You can’t perform that action at this time.
0 commit comments