-
Notifications
You must be signed in to change notification settings - Fork 11
chore: Improve Exception Handling and Accessors to Response/Request #529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…/ai-sdk-java into exceptions-with-httpresponse
@@ -102,7 +101,7 @@ public static void send(@Nonnull final ResponseBodyEmitter emitter, @Nonnull fin | |||
try { | |||
emitter.send(chunk); | |||
} catch (final IOException e) { | |||
log.error(Arrays.toString(e.getStackTrace())); | |||
log.error("Failed to send chunk: {}", e.getMessage(), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor drive-by change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I really like the functional interface approach.
I just had one question/suggestion.
Otherwise, I would approve.
@Getter(onMethod_ = @Beta, value = AccessLevel.PROTECTED) | ||
@Setter(onMethod_ = @Beta, value = AccessLevel.PROTECTED) | ||
ClientError clientError; | ||
@Getter(onMethod_ = @Beta, value = AccessLevel.PUBLIC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Question/Suggestion)
Should getClientError()
remain protected
? As far as I see, ClientError
is an internal wrapper for error response.
For users, there exist a getErrorResponse()
in module specific exceptions like OpenAiClientException
to shortcut access to the error response.
I feel like getErrorResponse()
is convenient than getClientError()
and would reduce confusion. Having both method public
may be redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following API is available
catch(OrchestrationClientException e) {
e.getMessage(); // default
e.getCause(); // default
e.getHttpResponse(); // ClassicHttpResponse
e.getHttpRequest(); // ClassicHttpRequest
e.getClientError().getMessage(); // convenient message
e.getErrorResponse(); // ErrorResponse (model class)
e.getErrorResponseStreaming(); // ErrorResponseStreaming (model class)
}
The e.getClientError().getMessage()
is the reason.
However I would also prefer if it wasn't split.
…esponse # Conflicts: # docs/release_notes.md # orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationClientException.java # orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationExceptionFactory.java # orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationHttpExecutor.java
…to exceptions-with-httpresponse
Context
https://github.com/SAP/ai-sdk-java-backlog/issues/290
Since we removed logging of HTTP request/responses from our code, we want to ease troubleshooting in the future.
Feature scope:
pubic
accessorDefinition of Done
Aligned changes with the JavaScript SDKDocumentation updated