|
1 | | -from typing import List |
| 1 | +import datetime |
| 2 | +from typing import List, Type |
2 | 3 |
|
3 | 4 | from ._response import FlyMyAIResponse |
4 | 5 | from .models.error_responses import ( |
@@ -32,13 +33,20 @@ def from_5xx(cls, response: FlyMyAIResponse): |
32 | 33 | msg = f""" |
33 | 34 | INTERNAL SERVER ERROR ({response.status_code}): |
34 | 35 | REQUEST URL: {response.url}; |
35 | | - """ |
| 36 | + Content [0:250]: {response.content.decode()[0:250]} |
| 37 | + Timestamp [UTC]: {datetime.datetime.utcnow()} |
| 38 | + """ |
36 | 39 | internal_error_mapping = { |
37 | 40 | 500: lambda: cls(msg, False, response=response), |
38 | 41 | 502: lambda: cls(msg, True, response=response), |
39 | 42 | 503: lambda: cls(msg, False, response=response), |
40 | 43 | 504: lambda: cls(msg, True, response=response), |
41 | 44 | 524: lambda: cls(msg, True, response=response), |
| 45 | + # unknown issue, probably detected on the client side |
| 46 | + 599: lambda: cls(msg, False, response=response), |
| 47 | + # broker issues, they are not billed at all |
| 48 | + 5000: lambda: cls(msg, False, response=response), |
| 49 | + 5320: lambda: cls(msg, True, response=response), |
42 | 50 | } |
43 | 51 | return internal_error_mapping.get( |
44 | 52 | response.status_code, lambda: cls(msg, False) |
@@ -72,7 +80,10 @@ def __str__(self): |
72 | 80 | return self.msg |
73 | 81 |
|
74 | 82 |
|
75 | | -class FlyMyAIPredictException(BaseFlyMyAIException): ... |
| 83 | +class FlyMyAIPredictException(BaseFlyMyAIException): |
| 84 | + @classmethod |
| 85 | + def from_base_exception(cls, exception: BaseFlyMyAIException): |
| 86 | + return cls(exception.msg, exception.requires_retry, exception.response) |
76 | 87 |
|
77 | 88 |
|
78 | 89 | class FlyMyAIOpenAPIException(BaseFlyMyAIException): ... |
|
0 commit comments