mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 06:55:45 +00:00
Added exception for NetworkError, to get specific error from connection class.
This commit is contained in:
parent
872eec40c4
commit
a864f8b7e1
@ -5,11 +5,13 @@
|
||||
|
||||
import logging
|
||||
from importlib import import_module
|
||||
|
||||
import tarantool
|
||||
|
||||
from planetmint.config import Config
|
||||
from planetmint.backend.exceptions import ConnectionError
|
||||
from planetmint.transactions.common.exceptions import ConfigurationError
|
||||
|
||||
|
||||
BACKENDS = { # This is path to MongoDBClass
|
||||
'tarantool_db': 'planetmint.backend.tarantool.connection.TarantoolDB',
|
||||
'localmongodb': 'planetmint.backend.localmongodb.connection.LocalMongoDBConnection'
|
||||
@ -67,10 +69,14 @@ def Connection(host: str = None, port: int = None, login: str = None, password:
|
||||
replicaset=replicaset, ssl=ssl, login=login, password=password,
|
||||
ca_cert=ca_cert, certfile=certfile, keyfile=keyfile,
|
||||
keyfile_passphrase=keyfile_passphrase, crlfile=crlfile)
|
||||
except tarantool.error.NetworkError as network_err:
|
||||
print(f"Host {host}:{port} can't be reached.\n{network_err}")
|
||||
raise network_err
|
||||
except:
|
||||
logger.info('Exception in _connect(): {}')
|
||||
raise ConfigurationError
|
||||
|
||||
|
||||
def _kwargs_parser(key, kwargs):
|
||||
if kwargs.get(key):
|
||||
return kwargs[key]
|
||||
|
||||
@ -33,6 +33,9 @@ class TarantoolDB:
|
||||
self.SPACE_NAMES = ["abci_chains", "assets", "blocks", "blocks_tx",
|
||||
"elections", "meta_data", "pre_commits", "validators",
|
||||
"transactions", "inputs", "outputs", "keys"]
|
||||
except tarantool.error.NetworkError as network_err:
|
||||
logger.info('Host cant be reached')
|
||||
raise network_err
|
||||
except:
|
||||
logger.info('Exception in _connect(): {}')
|
||||
raise ConfigurationError
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user