Skip to content

Commit dd828d0

Browse files
SDK regeneration
1 parent a665131 commit dd828d0

47 files changed

Lines changed: 150 additions & 207 deletions

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": "DeepgramApiException",
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": "aa80de0e6348f76fb3fbb9cb17fdbe613222dd13",
15+
"sdkVersion": "0.1.1"
1416
}

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

Lines changed: 0 additions & 73 deletions
This file was deleted.

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

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,71 @@
33
*/
44
package com.deepgram.core;
55

6+
import java.util.ArrayList;
7+
import java.util.HashMap;
8+
import java.util.List;
9+
import java.util.Map;
10+
import okhttp3.Response;
11+
612
/**
7-
* This class serves as the base exception for all errors in the SDK.
13+
* This exception type will be thrown for any non-2XX API responses.
814
*/
9-
public class DeepgramApiException extends RuntimeException {
10-
public DeepgramApiException(String message) {
15+
public class DeepgramApiException extends DeepgramApiException {
16+
/**
17+
* The error code of the response that triggered the exception.
18+
*/
19+
private final int statusCode;
20+
21+
/**
22+
* The body of the response that triggered the exception.
23+
*/
24+
private final Object body;
25+
26+
private final Map<String, List<String>> headers;
27+
28+
public DeepgramApiException(String message, int statusCode, Object body) {
29+
super(message);
30+
this.statusCode = statusCode;
31+
this.body = body;
32+
this.headers = new HashMap<>();
33+
}
34+
35+
public DeepgramApiException(String message, int statusCode, Object body, Response rawResponse) {
1136
super(message);
37+
this.statusCode = statusCode;
38+
this.body = body;
39+
this.headers = new HashMap<>();
40+
rawResponse.headers().forEach(header -> {
41+
String key = header.component1();
42+
String value = header.component2();
43+
this.headers.computeIfAbsent(key, _str -> new ArrayList<>()).add(value);
44+
});
45+
}
46+
47+
/**
48+
* @return the statusCode
49+
*/
50+
public int statusCode() {
51+
return this.statusCode;
52+
}
53+
54+
/**
55+
* @return the body
56+
*/
57+
public Object body() {
58+
return this.body;
59+
}
60+
61+
/**
62+
* @return the headers
63+
*/
64+
public Map<String, List<String>> headers() {
65+
return this.headers;
1266
}
1367

14-
public DeepgramApiException(String message, Exception e) {
15-
super(message, e);
68+
@Override
69+
public String toString() {
70+
return "DeepgramApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
71+
+ ObjectMappers.stringify(body) + "}";
1672
}
1773
}

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.DeepgramApiException;
77
import okhttp3.Response;
88

9-
public final class BadRequestError extends DeepgramApiApiException {
9+
public final class BadRequestError extends DeepgramApiException {
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
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;
109
import com.deepgram.core.ObjectMappers;
@@ -83,7 +82,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
8382
// unable to map error response, throwing generic error
8483
}
8584
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
86-
future.completeExceptionally(new DeepgramApiApiException(
85+
future.completeExceptionally(new DeepgramApiException(
8786
"Error with status code " + response.code(), response.code(), errorBody, response));
8887
return;
8988
} catch (IOException e) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
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;
109
import com.deepgram.core.ObjectMappers;
@@ -73,7 +72,7 @@ public DeepgramApiHttpResponse<AgentThinkModelsV1Response> list(RequestOptions r
7372
// unable to map error response, throwing generic error
7473
}
7574
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
76-
throw new DeepgramApiApiException(
75+
throw new DeepgramApiException(
7776
"Error with status code " + response.code(), response.code(), errorBody, response);
7877
} catch (IOException e) {
7978
throw new DeepgramApiException("Network error executing HTTP request", e);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
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;
109
import com.deepgram.core.MediaTypes;
@@ -108,7 +107,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
108107
// unable to map error response, throwing generic error
109108
}
110109
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
111-
future.completeExceptionally(new DeepgramApiApiException(
110+
future.completeExceptionally(new DeepgramApiException(
112111
"Error with status code " + response.code(), response.code(), errorBody, response));
113112
return;
114113
} catch (IOException e) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
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;
109
import com.deepgram.core.MediaTypes;
@@ -97,7 +96,7 @@ public DeepgramApiHttpResponse<GrantV1Response> grant(GrantV1Request request, Re
9796
// unable to map error response, throwing generic error
9897
}
9998
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
100-
throw new DeepgramApiApiException(
99+
throw new DeepgramApiException(
101100
"Error with status code " + response.code(), response.code(), errorBody, response);
102101
} catch (IOException e) {
103102
throw new DeepgramApiException("Network error executing HTTP request", e);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
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;
109
import com.deepgram.core.InputStreamRequestBody;
@@ -243,7 +242,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
243242
// unable to map error response, throwing generic error
244243
}
245244
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
246-
future.completeExceptionally(new DeepgramApiApiException(
245+
future.completeExceptionally(new DeepgramApiException(
247246
"Error with status code " + response.code(), response.code(), errorBody, response));
248247
return;
249248
} catch (IOException e) {
@@ -475,7 +474,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
475474
// unable to map error response, throwing generic error
476475
}
477476
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
478-
future.completeExceptionally(new DeepgramApiApiException(
477+
future.completeExceptionally(new DeepgramApiException(
479478
"Error with status code " + response.code(), response.code(), errorBody, response));
480479
return;
481480
} catch (IOException e) {

0 commit comments

Comments
 (0)