Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Unwrap SocketTimeoutException and update tests accordingly #373

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LeonardoEmili
Copy link

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 type SocketTimeoutException.

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant