Skip to content

Commit 410ea00

Browse files
committed
Including the underlying errors in the error message for Timeout & APIConnectionError
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 dc33cb9 commit 410ea00

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
@@ -363,9 +363,9 @@ def request_raw(
363363
timeout=request_timeout if request_timeout else TIMEOUT_SECS,
364364
)
365365
except requests.exceptions.Timeout as e:
366-
raise error.Timeout("Request timed out") from e
366+
raise error.Timeout("Request timed out: {}".format(e)) from e
367367
except requests.exceptions.RequestException as e:
368-
raise error.APIConnectionError("Error communicating with OpenAI") from e
368+
raise error.APIConnectionError("Error communicating with OpenAI: {}".format(e)) from e
369369
util.log_info(
370370
"OpenAI API response",
371371
path=abs_url,

0 commit comments

Comments
 (0)