Skip to content

Commit

Permalink
Including the underlying errors in the error message for Timeout & AP…
Browse files Browse the repository at this point in the history
…IConnectionError (openai#137)

Many libraries will only show the error string of the raised error,
not displaying its cause. Prior to this path, this would mean that
the many different kinds of connection errors get translated into a
single opaque "Error communicating with OpenAI".
  • Loading branch information
gdb authored Jan 6, 2023
1 parent abadf12 commit 65d84b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions openai/api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ def request_raw(
timeout=request_timeout if request_timeout else TIMEOUT_SECS,
)
except requests.exceptions.Timeout as e:
raise error.Timeout("Request timed out") from e
raise error.Timeout("Request timed out: {}".format(e)) from e
except requests.exceptions.RequestException as e:
raise error.APIConnectionError("Error communicating with OpenAI") from e
raise error.APIConnectionError("Error communicating with OpenAI: {}".format(e)) from e
util.log_info(
"OpenAI API response",
path=abs_url,
Expand Down

0 comments on commit 65d84b4

Please sign in to comment.