@@ -22,7 +22,7 @@ class ServiceStatusError(NaasException):
22
22
23
23
class BaseAPIAdaptor (NaasSpaceAuthenticatorAdapter ):
24
24
host = os .environ .get ("NAAS_PYTHON_API_BASE_URL" , "https://api.naas.ai" )
25
- # host = os.environ.get("NAAS_PYTHON_API_BASE_URL", "http://localhost:8000")
25
+ #host = os.environ.get("NAAS_PYTHON_API_BASE_URL", "http://localhost:8000")
26
26
# Cache name is the name of the calling module
27
27
cache_name = __name__
28
28
cache_expire_after = 60 # Cache expires after 60 seconds
@@ -89,8 +89,8 @@ def make_api_request(
89
89
return api_response
90
90
91
91
except requests .exceptions .HTTPError as e :
92
+ _response = api_response .json ()
92
93
if api_response .status_code == 401 :
93
- _response = api_response .json ()
94
94
_message = ""
95
95
if "error_message" in _response :
96
96
_message = _response ["error_message" ]
@@ -103,7 +103,13 @@ def make_api_request(
103
103
e ,
104
104
)
105
105
elif api_response .status_code == 500 :
106
- _message = "Internal Server Error"
106
+ _message = ""
107
+ if "error_message" in _response :
108
+ _message = _response ["error_message" ]
109
+ elif "detail" in _response :
110
+ _message = _response ["detail" ]
111
+ else :
112
+ _message = "Internal Server Error"
107
113
raise ServiceStatusError (_message , e )
108
114
else :
109
115
# Other status codes will be handled by the calling method
0 commit comments