2021-04-04 14:55:27 +02:00
|
|
|
|
# TODO: use json-rpc module
|
2021-08-21 09:31:59 +02:00
|
|
|
|
class RPCException(Exception):
|
|
|
|
|
"""Base RPC connection error
|
|
|
|
|
"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class JSONRPCException(RPCException):
|
|
|
|
|
"""Base JSON-RPC error
|
|
|
|
|
"""
|
2021-04-04 14:55:27 +02:00
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ExecutionError(Exception):
|
2021-08-21 09:31:59 +02:00
|
|
|
|
"""Base error for transaction execution failures
|
|
|
|
|
"""
|
2021-04-04 14:55:27 +02:00
|
|
|
|
pass
|
2021-08-21 09:31:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SignerMissingException(Exception):
|
|
|
|
|
"""Raised when attempting to retrieve a signer when none has been added
|
|
|
|
|
"""
|
2021-08-26 17:08:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RPCNonceException(RPCException):
|
|
|
|
|
"""RPC error for invalid nonce in transaction
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DefaultErrorParser:
|
|
|
|
|
"""Base class for parsing RPC error repsonses
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def translate(self, error):
|
|
|
|
|
"""Interface method called by unspeficied rpc when encountering an error
|
|
|
|
|
|
|
|
|
|
This class method should be overriden to provide more fine-grained context for both general and implementation specific errors.
|
|
|
|
|
|
|
|
|
|
:param error: RPC error response object
|
|
|
|
|
:type error: dict
|
|
|
|
|
:rtype: chainlib.error.JSONRPCException
|
|
|
|
|
:returns: Descriptiv JSONRPCException
|
|
|
|
|
"""
|
|
|
|
|
return RPCException('default parser code {}'.format(error))
|