Skip to content

Commit 9678e15

Browse files
authored
Including the underlying errors in the error message for Timeout & APIConnectionError (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".
1 parent 7af43ce commit 9678e15

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

openai/api_requestor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,9 @@ def request_raw(
505505
timeout=request_timeout if request_timeout else TIMEOUT_SECS,
506506
)
507507
except requests.exceptions.Timeout as e:
508-
raise error.Timeout("Request timed out") from e
508+
raise error.Timeout("Request timed out: {}".format(e)) from e
509509
except requests.exceptions.RequestException as e:
510-
raise error.APIConnectionError("Error communicating with OpenAI") from e
510+
raise error.APIConnectionError("Error communicating with OpenAI: {}".format(e)) from e
511511
util.log_info(
512512
"OpenAI API response",
513513
path=abs_url,

0 commit comments

Comments
 (0)