MCPcopy
hub / github.com/petertodd/python-bitcoinlib / JSONRPCError

Class JSONRPCError

bitcoin/rpc.py:75–100  ·  view source on GitHub ↗

JSON-RPC protocol error base class Subclasses of this class also exist for specific types of errors; the set of all subclasses is by no means complete.

Source from the content-addressed store, hash-verified

73
74
75class JSONRPCError(Exception):
76 """JSON-RPC protocol error base class
77
78 Subclasses of this class also exist for specific types of errors; the set
79 of all subclasses is by no means complete.
80 """
81
82 SUBCLS_BY_CODE = {}
83
84 @classmethod
85 def _register_subcls(cls, subcls):
86 cls.SUBCLS_BY_CODE[subcls.RPC_ERROR_CODE] = subcls
87 return subcls
88
89 def __new__(cls, rpc_error):
90 assert cls is JSONRPCError
91 cls = JSONRPCError.SUBCLS_BY_CODE.get(rpc_error['code'], cls)
92
93 self = Exception.__new__(cls)
94
95 super(JSONRPCError, self).__init__(
96 'msg: %r code: %r' %
97 (rpc_error['message'], rpc_error['code']))
98 self.error = rpc_error
99
100 return self
101
102@JSONRPCError._register_subcls
103class ForbiddenBySafeModeError(JSONRPCError):

Callers 2

_callMethod · 0.85
_get_responseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected