forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
followupThis is a possible follow-up someone can work onThis is a possible follow-up someone can work onneed to confirmNeed to confirm if this is still needed or already doneNeed to confirm if this is still needed or already done
Description
mentioned in: bitcoin#34575
"> * I think JSON-RPC 2 is meant to always use HTTP status 200 regardless of error but cannot find it in the specification, I guess adding it is okay, it's being sent in everywhere after all.
The old output on master
Method not found (-32601)
was nicer than the PR's
{'code': -32601, 'message': 'Method not found'} [http_status=200]
Yeah, happy to review a follow-up improving the wording. One could use something like (untested):
class JSONRPCException(Exception):
def __init__(self, rpc_error, http_status=None):
message = rpc_error.pop("message", "INTERNAL ERROR: message field missing in rpc error dict")
code = rpc_error.pop("code", "INTERNAL_ERROR: code field missing in rpc error dict")
extra = f'{rpc_error}' if rpc_error else ''
super().__init__(f"{message} ({code}) {extra} [http_status={http_status}]")
" - maflckoReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
followupThis is a possible follow-up someone can work onThis is a possible follow-up someone can work onneed to confirmNeed to confirm if this is still needed or already doneNeed to confirm if this is still needed or already done