From 410ea00e3b06d9c6ea50c91791da88210605f6af Mon Sep 17 00:00:00 2001 From: Greg Brockman Date: Fri, 11 Nov 2022 18:47:41 -0800 Subject: [PATCH] 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". --- openai/api_requestor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openai/api_requestor.py b/openai/api_requestor.py index 5970510434..0496770dfb 100644 --- a/openai/api_requestor.py +++ b/openai/api_requestor.py @@ -363,9 +363,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,