We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc33cb9 commit 944029fCopy full SHA for 944029f
openai/error.py
@@ -1,4 +1,7 @@
1
import openai
2
+import os
3
+
4
+display_cause = os.environ["OPENAI_ERROR_DISPLAY_CAUSE"]
5
6
7
class OpenAIError(Exception):
@@ -34,6 +37,8 @@ def __init__(
34
37
35
38
def __str__(self):
36
39
msg = self._message or "<empty message>"
40
+ if display_cause is not None and hasattr(self, "__cause__") and self.__cause__ is not None:
41
+ msg += " (Cause: {0})".format(self.__cause__)
42
if self.request_id is not None:
43
return "Request {0}: {1}".format(self.request_id, msg)
44
else:
0 commit comments