You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 12, 2022. It is now read-only.
Is it possible to return a specific Response object even the server is under maintenance? Currently, when the server is not reachable, it returns:
File "/path/to/file.py", line 141, in extract_from_text response = self.recast.request.analyse_text(text=text) File "/path/to/env/lib/python3.6/site-packages/recastai/apis/request/analyse.py", line 30, in analyse_text raise RecastError(response.json().get('message', '')) File "/path/to/env/lib/python3.6/site-packages/requests/models.py", line 808, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The idea is to get a response message in order to be able to use the status code from the response and avoid catching the JSONDecodeError. { "message": "Requests rendered with success", "results": { "act": "wh-query", "entities": {}, "intents": [], "language": "fr", "processing_language": "fr", "sentiment": "negative", "source": "Pourquoi?", "status": 500, "timestamp": "2017-09-14T17:30:16.467673+00:00", "type": "desc:reason", "uuid": "c443d4fc-f6a6-41d3-8835-54627bd24c49", "version": "2.9.0" } }
Cheers,
JP
The text was updated successfully, but these errors were encountered:
Thanks for the issue.
The way we could handle this is to move the line raising the parsing error ( namely: response.json().get('message', '')) into the RecastError's __init__ method to handle the whole error message parsing logic over there.
We'll take a look into this, but in the meantime, feel free to submit a PR :)
Hi,
Is it possible to return a specific Response object even the server is under maintenance? Currently, when the server is not reachable, it returns:
File "/path/to/file.py", line 141, in extract_from_text response = self.recast.request.analyse_text(text=text) File "/path/to/env/lib/python3.6/site-packages/recastai/apis/request/analyse.py", line 30, in analyse_text raise RecastError(response.json().get('message', '')) File "/path/to/env/lib/python3.6/site-packages/requests/models.py", line 808, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The idea is to get a response message in order to be able to use the status code from the response and avoid catching the JSONDecodeError.
{ "message": "Requests rendered with success", "results": { "act": "wh-query", "entities": {}, "intents": [], "language": "fr", "processing_language": "fr", "sentiment": "negative", "source": "Pourquoi?", "status": 500, "timestamp": "2017-09-14T17:30:16.467673+00:00", "type": "desc:reason", "uuid": "c443d4fc-f6a6-41d3-8835-54627bd24c49", "version": "2.9.0" } }
Cheers,
JP
The text was updated successfully, but these errors were encountered: