refactor: Update get_message_from_openai_exception to handle None return value
This commit is contained in:
parent
2b1d46e883
commit
b8b14bb36a
1 changed files with 2 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
def get_message_from_openai_exception(exception: Exception) -> str:
|
def get_message_from_openai_exception(exception: Exception) -> str | None:
|
||||||
"""
|
"""
|
||||||
Get a message from an OpenAI exception.
|
Get a message from an OpenAI exception.
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ def get_message_from_openai_exception(exception: Exception) -> str:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return
|
return
|
||||||
if isinstance(exception, BadRequestError):
|
if isinstance(exception, BadRequestError):
|
||||||
message = exception.body.get("message")
|
message = exception.body.get("message") # type: ignore
|
||||||
if message:
|
if message:
|
||||||
return message
|
return message
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue