Skip to content
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

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

Conversation

ParthSareen
Copy link
Contributor

@ParthSareen ParthSareen commented Dec 29, 2024

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

  • Tests

@ParthSareen ParthSareen changed the title Improve error messaging on connection failure client: Improve error messaging on connection failure Dec 29, 2024
@ParthSareen ParthSareen force-pushed the parth/qol-improve-connection-error-message branch from 2d717e6 to efe8e57 Compare December 29, 2024 22:52
Comment on lines +528 to +529
def __str__(self) -> str:
return f'{self.error} (status code: {self.status_code})'
Copy link
Contributor Author

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

@ParthSareen ParthSareen marked this pull request as ready for review December 29, 2024 22:55
@ParthSareen ParthSareen force-pushed the parth/qol-improve-connection-error-message branch from efe8e57 to db25d87 Compare December 29, 2024 23:02
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
Copy link
Member

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

Copy link
Contributor Author

@ParthSareen ParthSareen Dec 29, 2024

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

Copy link
Contributor Author

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

@ParthSareen ParthSareen force-pushed the parth/qol-improve-connection-error-message branch 2 times, most recently from cd62955 to 03e494e Compare January 7, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants