This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
Unwrap SocketTimeoutException and update tests accordingly #373
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, thanks for the great work, it's very simple and easy to use.
When working with the library I found it a bit strange that currently the API returns an OpenAiHttpException when the token-per-minute wall is met but only a generic RuntimeException when a timeout on the OpenAI APIs is reached. This is a bit counterintuitive to me because, in order to catch it, I have to get the parent exception via the
getCause()
method and check if this was rather of typeSocketTimeoutException
.This PR raises the level of the exception to the more specific
SocketTimeoutException
, so that it's easier on the client-side to handle these cases. Tests are updated accordingly so to pass successfully.Note that this exception could easily be integrated into an
OpenAiHttpException
as I believe mean similar concepts. Still, I didn't make the effort to do it but could be easily integrated to this PR.@TheoKanning @aaronuu @Grogdunn