Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"generatorVersion": "4.0.4",
"generatorConfig": {
"package-prefix": "com.deepgram",
"base-api-exception-class-name": "DeepgramHttpException",
"enable-forward-compatible-enums": true,
"client": {
"class-name": "DeepgramClient"
},
"enable-wire-tests": true
},
"originGitCommit": "78fd4d4c60752a78daaa68b3d58da0554c9ce481",
"sdkVersion": "0.1.0"
"originGitCommit": "e994b5ab79ae6fe3560daff055acdf80d315b48e",
"sdkVersion": "0.1.1"
}
8 changes: 4 additions & 4 deletions examples/advanced/ErrorHandling.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import com.deepgram.DeepgramClient;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.errors.BadRequestError;
import com.deepgram.resources.listen.v1.media.requests.ListenV1RequestUrl;
import com.deepgram.resources.listen.v1.media.types.MediaTranscribeResponse;
Expand Down Expand Up @@ -40,7 +40,7 @@ public static void main(String[] args) {
System.out.println(" Status: " + e.statusCode());
System.out.println(" Body: " + e.body());
System.out.println(" Message: " + e.getMessage());
} catch (DeepgramApiApiException e) {
} catch (DeepgramHttpException e) {
System.out.println(" Caught API error");
System.out.println(" Status: " + e.statusCode());
System.out.println(" Body: " + e.body());
Expand All @@ -61,7 +61,7 @@ public static void main(String[] args) {
badClient.manage().v1().projects().list();
System.out.println("Unexpected success");

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

} catch (DeepgramApiApiException e) {
} catch (DeepgramHttpException e) {
System.err.println(" API error: " + e.statusCode() + " - " + e.body());
} catch (Exception e) {
System.err.println(" Unexpected error: " + e.getMessage());
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/deepgram/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ private ClientOptions(
this.headers.putAll(headers);
this.headers.putAll(new HashMap<String, String>() {
{
put("User-Agent", "com.deepgram:deepgram-java-sdk/0.1.0");
put("User-Agent", "com.deepgram:deepgram-sdk/0.1.1");
put("X-Fern-Language", "JAVA");
put("X-Fern-SDK-Name", "com.deepgram:deepgram-java-sdk");
put("X-Fern-SDK-Version", "0.1.0");
put("X-Fern-SDK-Name", "com.deepgram.fern:api-sdk");
put("X-Fern-SDK-Version", "0.1.1");
}
});
this.headerSuppliers = headerSuppliers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* This exception type will be thrown for any non-2XX API responses.
*/
public class DeepgramApiApiException extends DeepgramApiException {
public class DeepgramHttpException extends DeepgramApiException {
/**
* The error code of the response that triggered the exception.
*/
Expand All @@ -25,14 +25,14 @@ public class DeepgramApiApiException extends DeepgramApiException {

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

public DeepgramApiApiException(String message, int statusCode, Object body) {
public DeepgramHttpException(String message, int statusCode, Object body) {
super(message);
this.statusCode = statusCode;
this.body = body;
this.headers = new HashMap<>();
}

public DeepgramApiApiException(String message, int statusCode, Object body, Response rawResponse) {
public DeepgramHttpException(String message, int statusCode, Object body, Response rawResponse) {
super(message);
this.statusCode = statusCode;
this.body = body;
Expand Down Expand Up @@ -67,7 +67,7 @@ public Map<String, List<String>> headers() {

@Override
public String toString() {
return "DeepgramApiApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
return "DeepgramHttpException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: "
+ ObjectMappers.stringify(body) + "}";
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/deepgram/errors/BadRequestError.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*/
package com.deepgram.errors;

import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramHttpException;
import okhttp3.Response;

public final class BadRequestError extends DeepgramApiApiException {
public final class BadRequestError extends DeepgramHttpException {
/**
* The body of the response that triggered the exception.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.agent.v1.settings.think.models;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.ObjectMappers;
import com.deepgram.core.RequestOptions;
import com.deepgram.errors.BadRequestError;
Expand Down Expand Up @@ -83,7 +83,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.agent.v1.settings.think.models;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.ObjectMappers;
import com.deepgram.core.RequestOptions;
import com.deepgram.errors.BadRequestError;
Expand Down Expand Up @@ -73,7 +73,7 @@ public DeepgramApiHttpResponse<AgentThinkModelsV1Response> list(RequestOptions r
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new DeepgramApiApiException(
throw new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new DeepgramApiException("Network error executing HTTP request", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.auth.v1.tokens;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.MediaTypes;
import com.deepgram.core.ObjectMappers;
import com.deepgram.core.RequestOptions;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.auth.v1.tokens;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.MediaTypes;
import com.deepgram.core.ObjectMappers;
import com.deepgram.core.RequestOptions;
Expand Down Expand Up @@ -97,7 +97,7 @@ public DeepgramApiHttpResponse<GrantV1Response> grant(GrantV1Request request, Re
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new DeepgramApiApiException(
throw new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new DeepgramApiException("Network error executing HTTP request", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.listen.v1.media;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.InputStreamRequestBody;
import com.deepgram.core.MediaTypes;
import com.deepgram.core.ObjectMappers;
Expand Down Expand Up @@ -243,7 +243,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down Expand Up @@ -475,7 +475,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.listen.v1.media;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.InputStreamRequestBody;
import com.deepgram.core.MediaTypes;
import com.deepgram.core.ObjectMappers;
Expand Down Expand Up @@ -233,7 +233,7 @@ public DeepgramApiHttpResponse<MediaTranscribeResponse> transcribeUrl(
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new DeepgramApiApiException(
throw new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new DeepgramApiException("Network error executing HTTP request", e);
Expand Down Expand Up @@ -449,7 +449,7 @@ public DeepgramApiHttpResponse<MediaTranscribeResponse> transcribeFile(
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new DeepgramApiApiException(
throw new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new DeepgramApiException("Network error executing HTTP request", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.manage.v1.models;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.ObjectMappers;
import com.deepgram.core.QueryStringMapper;
import com.deepgram.core.RequestOptions;
Expand Down Expand Up @@ -104,7 +104,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down Expand Up @@ -173,7 +173,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.manage.v1.models;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.ObjectMappers;
import com.deepgram.core.QueryStringMapper;
import com.deepgram.core.RequestOptions;
Expand Down Expand Up @@ -94,7 +94,7 @@ public DeepgramApiHttpResponse<ListModelsV1Response> list(
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new DeepgramApiApiException(
throw new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new DeepgramApiException("Network error executing HTTP request", e);
Expand Down Expand Up @@ -147,7 +147,7 @@ public DeepgramApiHttpResponse<GetModelV1Response> get(String modelId, RequestOp
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
throw new DeepgramApiApiException(
throw new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response);
} catch (IOException e) {
throw new DeepgramApiException("Network error executing HTTP request", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package com.deepgram.resources.manage.v1.projects;

import com.deepgram.core.ClientOptions;
import com.deepgram.core.DeepgramApiApiException;
import com.deepgram.core.DeepgramApiException;
import com.deepgram.core.DeepgramApiHttpResponse;
import com.deepgram.core.DeepgramHttpException;
import com.deepgram.core.MediaTypes;
import com.deepgram.core.ObjectMappers;
import com.deepgram.core.QueryStringMapper;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down Expand Up @@ -184,7 +184,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down Expand Up @@ -253,7 +253,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down Expand Up @@ -346,7 +346,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down Expand Up @@ -416,7 +416,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
// unable to map error response, throwing generic error
}
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
future.completeExceptionally(new DeepgramApiApiException(
future.completeExceptionally(new DeepgramHttpException(
"Error with status code " + response.code(), response.code(), errorBody, response));
return;
} catch (IOException e) {
Expand Down
Loading
Loading