Add openethereum error parser, add dialect processor to config from args

This commit is contained in:
nolash
2021-08-26 17:10:39 +02:00
parent 5b1755e50d
commit 6c19cd38b0
7 changed files with 50 additions and 12 deletions

View File

@@ -0,0 +1,9 @@
# local imports
from chainlib.eth.error import EthException
class DefaultErrorParser:
"""Generate eth specific exception for the default json-rpc query error parser.
"""
def translate(self, error):
return EthException('default parser code {}'.format(error))

View File

@@ -0,0 +1,17 @@
# standard imports
import logging
# local imports
from chainlib.eth.dialect import DefaultErrorParser
from chainlib.error import RPCNonceException
logg = logging.getLogger(__name__)
class DialectErrorParser(DefaultErrorParser):
def translate(self, error):
if error['error']['code'] == -32010:
if 'nonce is too low' in error['error']['message']:
return RPCNonceException(error)
return super(DialectErrorParser, self).translate(error)