in aidial_adapter_bedrock/server/exceptions.py [0:0]
def to_dial_exception(e: Exception) -> DialException:
if (
isinstance(e, ClientError)
and hasattr(e, "response")
and isinstance(e.response, dict)
):
response = e.response
log.debug(
f"botocore.exceptions.ClientError.response: {json.dumps(response)}"
)
if error := _get_content_filter_error(response):
return error
status_code = (
_get_response_error_code(response)
or _get_meta_status_code(response)
or 500
)
return create_error(status_code, str(e))
if isinstance(e, APIStatusError):
return create_error(e.status_code, e.message)
if isinstance(e, ValidationError):
return e.to_dial_exception()
if isinstance(e, UserError):
return e.to_dial_exception()
if isinstance(e, DialException):
return e
return InternalServerError(str(e))