mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 10:45:00 +00:00
refactor: improve API error messages and display format
This commit is contained in:
parent
3b2f1f1e66
commit
bfa9dce1e0
1 changed files with 7 additions and 7 deletions
|
@ -797,28 +797,28 @@ class Coder:
|
||||||
|
|
||||||
if isinstance(exc, (openai.APITimeoutError, openai.APIConnectionError)):
|
if isinstance(exc, (openai.APITimeoutError, openai.APIConnectionError)):
|
||||||
friendly_msg = (
|
friendly_msg = (
|
||||||
"The API provider is having connectivity issues. Please try again in a moment."
|
"There is a problem connecting to the API provider."
|
||||||
)
|
)
|
||||||
elif isinstance(exc, openai.RateLimitError):
|
elif isinstance(exc, openai.RateLimitError):
|
||||||
friendly_msg = (
|
friendly_msg = (
|
||||||
"The API provider's rate limits have been exceeded. Please wait a moment before"
|
"The API provider's rate limits have been exceeded. Check with your provider or wait awhile and retry."
|
||||||
" trying again."
|
|
||||||
)
|
)
|
||||||
elif isinstance(exc, openai.InternalServerError):
|
elif isinstance(exc, openai.InternalServerError):
|
||||||
friendly_msg = (
|
friendly_msg = (
|
||||||
"The API provider is experiencing internal issues. Please try again later."
|
"The API provider seems to be down or overloaded. Please try again later."
|
||||||
)
|
)
|
||||||
elif isinstance(exc, openai.BadRequestError):
|
elif isinstance(exc, openai.BadRequestError):
|
||||||
friendly_msg = (
|
friendly_msg = (
|
||||||
"The request was invalid. This might be due to the API provider changing their API."
|
"The API provider refused the request as invalid?"
|
||||||
)
|
)
|
||||||
elif isinstance(exc, openai.AuthenticationError):
|
elif isinstance(exc, openai.AuthenticationError):
|
||||||
friendly_msg = (
|
friendly_msg = (
|
||||||
"There was an issue with your API authentication. Please check your API key."
|
"The API provider refused your authentication. Please check that you are using a valid API key."
|
||||||
)
|
)
|
||||||
|
|
||||||
if friendly_msg:
|
if friendly_msg:
|
||||||
self.io.tool_error(f"{friendly_msg}\nTechnical details: {text}")
|
self.io.tool_warning(text)
|
||||||
|
self.io.tool_error(f"{friendly_msg}")
|
||||||
else:
|
else:
|
||||||
self.io.tool_error(text)
|
self.io.tool_error(text)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue