fixed improper error handling when data is not valid JSON (#1326)

This commit is contained in:
hackrush 2018-07-30 19:08:36 +05:30 committed by Lex Berezhny
parent 88b8ca8a49
commit 9ab256df30
2 changed files with 5 additions and 4 deletions

View file

@ -14,7 +14,7 @@ at anytime.
### Fixed
* loggly error reporting not following `share_usage_data`
*
* improper error handling when data is not valid JSON
### Deprecated
* automatic claim renew, this is no longer needed

View file

@ -298,12 +298,13 @@ class AuthJSONRPCServer(AuthorizedBase):
# maybe its a twisted Failure with another type of error
error = JSONRPCError(failure.getErrorMessage() or failure.type.__name__,
traceback=failure.getTraceback())
else:
# last resort, just cast it as a string
error = JSONRPCError(str(failure))
if not failure.check(ComponentsNotStarted, ComponentStartConditionNotMet):
log.warning("error processing api request: %s\ntraceback: %s", error.message,
"\n".join(error.traceback))
else:
# last resort, just cast it as a string
error = JSONRPCError(str(failure))
response_content = jsonrpc_dumps_pretty(error, id=id_)
self._set_headers(request, response_content)
request.setResponseCode(200)