Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Server maintenance return correct status code #5

Description

@jmanprz

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions