mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add some exception handling to file_config() config loader
This commit is contained in:
parent
011e840cf5
commit
3f53e67c65
@ -22,6 +22,7 @@ from pkg_resources import iter_entry_points, ResolutionError
|
||||
|
||||
import bigchaindb
|
||||
from bigchaindb.consensus import AbstractConsensusRules
|
||||
from bigchaindb import exceptions
|
||||
|
||||
# TODO: move this to a proper configuration file for logging
|
||||
logging.getLogger('requests').setLevel(logging.WARNING)
|
||||
@ -97,8 +98,11 @@ def file_config(filename=None):
|
||||
filename = CONFIG_DEFAULT_PATH
|
||||
|
||||
logger.debug('file_config() will try to open `{}`'.format(filename))
|
||||
try:
|
||||
with open(filename) as f:
|
||||
config = json.load(f)
|
||||
except Exception as err:
|
||||
raise exceptions.ConfigurationError('Failed to load configuration from `{}`, reason: {}'.format(filename, err))
|
||||
|
||||
logger.info('Configuration loaded from `{}`'.format(filename))
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
"""Custom exceptions used in the `bigchaindb` package.
|
||||
"""
|
||||
|
||||
class ConfigurationError(Exception):
|
||||
"""Raised when there is a problem with server configuration"""
|
||||
|
||||
|
||||
class OperationError(Exception):
|
||||
"""Raised when an operation cannot go through"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user