Skip to content

Commit 8d65065

Browse files
feat!: fern regeneration with exception rename and forward-compatible enums (#20)
* SDK regeneration * fix: update exception references from DeepgramApiApiException to DeepgramHttpException --------- Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: Greg Holmes <greg.holmes@deepgram.com>
1 parent a665131 commit 8d65065

48 files changed

Lines changed: 142 additions & 140 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.fern/metadata.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
"generatorVersion": "4.0.4",
55
"generatorConfig": {
66
"package-prefix": "com.deepgram",
7+
"base-api-exception-class-name": "DeepgramHttpException",
8+
"enable-forward-compatible-enums": true,
79
"client": {
810
"class-name": "DeepgramClient"
911
},
1012
"enable-wire-tests": true
1113
},
12-
"originGitCommit": "78fd4d4c60752a78daaa68b3d58da0554c9ce481",
13-
"sdkVersion": "0.1.0"
14+
"originGitCommit": "e994b5ab79ae6fe3560daff055acdf80d315b48e",
15+
"sdkVersion": "0.1.1"
1416
}

examples/advanced/ErrorHandling.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import com.deepgram.DeepgramClient;
2-
import com.deepgram.core.DeepgramApiApiException;
2+
import com.deepgram.core.DeepgramHttpException;
33
import com.deepgram.errors.BadRequestError;
44
import com.deepgram.resources.listen.v1.media.requests.ListenV1RequestUrl;
55
import com.deepgram.resources.listen.v1.media.types.MediaTranscribeResponse;
@@ -40,7 +40,7 @@ public static void main(String[] args) {
4040
System.out.println(" Status: " + e.statusCode());
4141
System.out.println(" Body: " + e.body());
4242
System.out.println(" Message: " + e.getMessage());
43-
} catch (DeepgramApiApiException e) {
43+
} catch (DeepgramHttpException e) {
4444
System.out.println(" Caught API error");
4545
System.out.println(" Status: " + e.statusCode());
4646
System.out.println(" Body: " + e.body());
@@ -61,7 +61,7 @@ public static void main(String[] args) {
6161
badClient.manage().v1().projects().list();
6262
System.out.println("Unexpected success");
6363

64-
} catch (DeepgramApiApiException e) {
64+
} catch (DeepgramHttpException e) {
6565
System.out.println(" Caught API error");
6666
System.out.println(" Status: " + e.statusCode());
6767
System.out.println(" Body: " + e.body());
@@ -84,7 +84,7 @@ public static void main(String[] args) {
8484
System.out.println(" Request succeeded");
8585
System.out.println(" Response: " + result);
8686

87-
} catch (DeepgramApiApiException e) {
87+
} catch (DeepgramHttpException e) {
8888
System.err.println(" API error: " + e.statusCode() + " - " + e.body());
8989
} catch (Exception e) {
9090
System.err.println(" Unexpected error: " + e.getMessage());

src/main/java/com/deepgram/core/ClientOptions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ private ClientOptions(
4141
this.headers.putAll(headers);
4242
this.headers.putAll(new HashMap<String, String>() {
4343
{
44-
put("User-Agent", "com.deepgram:deepgram-java-sdk/0.1.0");
44+
put("User-Agent", "com.deepgram:deepgram-sdk/0.1.1");
4545
put("X-Fern-Language", "JAVA");
46-
put("X-Fern-SDK-Name", "com.deepgram:deepgram-java-sdk");
47-
put("X-Fern-SDK-Version", "0.1.0");
46+
put("X-Fern-SDK-Name", "com.deepgram.fern:api-sdk");
47+
put("X-Fern-SDK-Version", "0.1.1");
4848
}
4949
});
5050
this.headerSuppliers = headerSuppliers;

src/main/java/com/deepgram/core/DeepgramApiApiException.java renamed to src/main/java/com/deepgram/core/DeepgramHttpException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* This exception type will be thrown for any non-2XX API responses.
1414
*/
15-
public class DeepgramApiApiException extends DeepgramApiException {
15+
public class DeepgramHttpException extends DeepgramApiException {
1616
/**
1717
* The error code of the response that triggered the exception.
1818
*/
@@ -25,14 +25,14 @@ public class DeepgramApiApiException extends DeepgramApiException {
2525

2626
private final Map<String, List<String>> headers;
2727

28-
public DeepgramApiApiException(String message, int statusCode, Object body) {
28+
public DeepgramHttpException(String message, int statusCode, Object body) {
2929
super(message);
3030
this.statusCode = statusCode;
3131
this.body = body;
3232
this.headers = new HashMap<>();
3333
}
3434

35-
public DeepgramApiApiException(String message, int statusCode, Object body, Response rawResponse) {
35+
public DeepgramHttpException(String message, int statusCode, Object body, Response rawResponse) {
3636
super(message);
3737
this.statusCode = statusCode;
3838
this.body = body;
@@ -67,7 +67,7 @@ public Map<String, List<String>> headers() {
6767

6868
@Override
6969
public String toString() {
70-
return "DeepgramApiApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
70+
return "DeepgramHttpException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
7171
+ ObjectMappers.stringify(body) + "}";
7272
}
7373
}

src/main/java/com/deepgram/errors/BadRequestError.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
*/
44
package com.deepgram.errors;
55

6-
import com.deepgram.core.DeepgramApiApiException;
6+
import com.deepgram.core.DeepgramHttpException;
77
import okhttp3.Response;
88

9-
public final class BadRequestError extends DeepgramApiApiException {
9+
public final class BadRequestError extends DeepgramHttpException {
1010
/**
1111
* The body of the response that triggered the exception.
1212
*/

src/main/java/com/deepgram/resources/agent/v1/settings/think/models/AsyncRawModelsClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package com.deepgram.resources.agent.v1.settings.think.models;
55

66
import com.deepgram.core.ClientOptions;
7-
import com.deepgram.core.DeepgramApiApiException;
87
import com.deepgram.core.DeepgramApiException;
98
import com.deepgram.core.DeepgramApiHttpResponse;
9+
import com.deepgram.core.DeepgramHttpException;
1010
import com.deepgram.core.ObjectMappers;
1111
import com.deepgram.core.RequestOptions;
1212
import com.deepgram.errors.BadRequestError;
@@ -83,7 +83,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
8383
// unable to map error response, throwing generic error
8484
}
8585
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
86-
future.completeExceptionally(new DeepgramApiApiException(
86+
future.completeExceptionally(new DeepgramHttpException(
8787
"Error with status code " + response.code(), response.code(), errorBody, response));
8888
return;
8989
} catch (IOException e) {

src/main/java/com/deepgram/resources/agent/v1/settings/think/models/RawModelsClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package com.deepgram.resources.agent.v1.settings.think.models;
55

66
import com.deepgram.core.ClientOptions;
7-
import com.deepgram.core.DeepgramApiApiException;
87
import com.deepgram.core.DeepgramApiException;
98
import com.deepgram.core.DeepgramApiHttpResponse;
9+
import com.deepgram.core.DeepgramHttpException;
1010
import com.deepgram.core.ObjectMappers;
1111
import com.deepgram.core.RequestOptions;
1212
import com.deepgram.errors.BadRequestError;
@@ -73,7 +73,7 @@ public DeepgramApiHttpResponse<AgentThinkModelsV1Response> list(RequestOptions r
7373
// unable to map error response, throwing generic error
7474
}
7575
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
76-
throw new DeepgramApiApiException(
76+
throw new DeepgramHttpException(
7777
"Error with status code " + response.code(), response.code(), errorBody, response);
7878
} catch (IOException e) {
7979
throw new DeepgramApiException("Network error executing HTTP request", e);

src/main/java/com/deepgram/resources/auth/v1/tokens/AsyncRawTokensClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package com.deepgram.resources.auth.v1.tokens;
55

66
import com.deepgram.core.ClientOptions;
7-
import com.deepgram.core.DeepgramApiApiException;
87
import com.deepgram.core.DeepgramApiException;
98
import com.deepgram.core.DeepgramApiHttpResponse;
9+
import com.deepgram.core.DeepgramHttpException;
1010
import com.deepgram.core.MediaTypes;
1111
import com.deepgram.core.ObjectMappers;
1212
import com.deepgram.core.RequestOptions;
@@ -108,7 +108,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
108108
// unable to map error response, throwing generic error
109109
}
110110
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
111-
future.completeExceptionally(new DeepgramApiApiException(
111+
future.completeExceptionally(new DeepgramHttpException(
112112
"Error with status code " + response.code(), response.code(), errorBody, response));
113113
return;
114114
} catch (IOException e) {

src/main/java/com/deepgram/resources/auth/v1/tokens/RawTokensClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package com.deepgram.resources.auth.v1.tokens;
55

66
import com.deepgram.core.ClientOptions;
7-
import com.deepgram.core.DeepgramApiApiException;
87
import com.deepgram.core.DeepgramApiException;
98
import com.deepgram.core.DeepgramApiHttpResponse;
9+
import com.deepgram.core.DeepgramHttpException;
1010
import com.deepgram.core.MediaTypes;
1111
import com.deepgram.core.ObjectMappers;
1212
import com.deepgram.core.RequestOptions;
@@ -97,7 +97,7 @@ public DeepgramApiHttpResponse<GrantV1Response> grant(GrantV1Request request, Re
9797
// unable to map error response, throwing generic error
9898
}
9999
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
100-
throw new DeepgramApiApiException(
100+
throw new DeepgramHttpException(
101101
"Error with status code " + response.code(), response.code(), errorBody, response);
102102
} catch (IOException e) {
103103
throw new DeepgramApiException("Network error executing HTTP request", e);

src/main/java/com/deepgram/resources/listen/v1/media/AsyncRawMediaClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package com.deepgram.resources.listen.v1.media;
55

66
import com.deepgram.core.ClientOptions;
7-
import com.deepgram.core.DeepgramApiApiException;
87
import com.deepgram.core.DeepgramApiException;
98
import com.deepgram.core.DeepgramApiHttpResponse;
9+
import com.deepgram.core.DeepgramHttpException;
1010
import com.deepgram.core.InputStreamRequestBody;
1111
import com.deepgram.core.MediaTypes;
1212
import com.deepgram.core.ObjectMappers;
@@ -243,7 +243,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
243243
// unable to map error response, throwing generic error
244244
}
245245
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
246-
future.completeExceptionally(new DeepgramApiApiException(
246+
future.completeExceptionally(new DeepgramHttpException(
247247
"Error with status code " + response.code(), response.code(), errorBody, response));
248248
return;
249249
} catch (IOException e) {
@@ -475,7 +475,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
475475
// unable to map error response, throwing generic error
476476
}
477477
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
478-
future.completeExceptionally(new DeepgramApiApiException(
478+
future.completeExceptionally(new DeepgramHttpException(
479479
"Error with status code " + response.code(), response.code(), errorBody, response));
480480
return;
481481
} catch (IOException e) {

0 commit comments

Comments
 (0)