-
Notifications
You must be signed in to change notification settings - Fork 486
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
client: Improve error messaging on connection failure #398
base: main
Are you sure you want to change the base?
Conversation
2d717e6
to
efe8e57
Compare
def __str__(self) -> str: | ||
return f'{self.error} (status code: {self.status_code})' |
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.
status code does not get printed currently - this exposes it
efe8e57
to
db25d87
Compare
ollama/_client.py
Outdated
except httpx.HTTPStatusError as e: | ||
raise ResponseError(e.response.text, e.response.status_code) from None | ||
return r | ||
except httpx.ConnectError: | ||
raise ResponseError('Failed to connect to Ollama. Please check that Ollama is downloaded, running and accessible. https://ollama.com/download', 503) from None |
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.
Shouldn't a 503 code be provided by the server? https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503 I wouldn't introduce any codes that aren't actually served by the API
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.
Yeah I'm debating if we should not have this as a ResponseError
since it's not even a response that is failing it's the connection from httpx itself
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.
Found a ConnectionError
throwable which I think makes more sense in this setting
cd62955
to
03e494e
Compare
Error messaging is unclear - especially on connection error
Also exposed the status code coming down but I'm not sure if we want that behavior