forked from LBRYCommunity/lbry-sdk
fixed improper error handling when data is not valid JSON (#1326)
This commit is contained in:
parent
88b8ca8a49
commit
9ab256df30
2 changed files with 5 additions and 4 deletions
|
@ -14,7 +14,7 @@ at anytime.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* loggly error reporting not following `share_usage_data`
|
* loggly error reporting not following `share_usage_data`
|
||||||
*
|
* improper error handling when data is not valid JSON
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
* automatic claim renew, this is no longer needed
|
* automatic claim renew, this is no longer needed
|
||||||
|
|
|
@ -298,12 +298,13 @@ class AuthJSONRPCServer(AuthorizedBase):
|
||||||
# maybe its a twisted Failure with another type of error
|
# maybe its a twisted Failure with another type of error
|
||||||
error = JSONRPCError(failure.getErrorMessage() or failure.type.__name__,
|
error = JSONRPCError(failure.getErrorMessage() or failure.type.__name__,
|
||||||
traceback=failure.getTraceback())
|
traceback=failure.getTraceback())
|
||||||
else:
|
|
||||||
# last resort, just cast it as a string
|
|
||||||
error = JSONRPCError(str(failure))
|
|
||||||
if not failure.check(ComponentsNotStarted, ComponentStartConditionNotMet):
|
if not failure.check(ComponentsNotStarted, ComponentStartConditionNotMet):
|
||||||
log.warning("error processing api request: %s\ntraceback: %s", error.message,
|
log.warning("error processing api request: %s\ntraceback: %s", error.message,
|
||||||
"\n".join(error.traceback))
|
"\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_)
|
response_content = jsonrpc_dumps_pretty(error, id=id_)
|
||||||
self._set_headers(request, response_content)
|
self._set_headers(request, response_content)
|
||||||
request.setResponseCode(200)
|
request.setResponseCode(200)
|
||||||
|
|
Loading…
Reference in a new issue