mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Move db exception to the right module
This commit is contained in:
parent
41043b7e6f
commit
a0761612ec
@ -1,17 +1,13 @@
|
|||||||
"""Utils to initialize and drop the database."""
|
"""Utils to initialize and drop the database."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import rethinkdb as r
|
import rethinkdb as r
|
||||||
|
|
||||||
import bigchaindb
|
import bigchaindb
|
||||||
|
from bigchaindb import exceptions
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class DatabaseAlreadyExistsException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_conn():
|
def get_conn():
|
||||||
'''Get the connection to the database.'''
|
'''Get the connection to the database.'''
|
||||||
|
|
||||||
@ -24,7 +20,7 @@ def init():
|
|||||||
dbname = bigchaindb.config['database']['name']
|
dbname = bigchaindb.config['database']['name']
|
||||||
|
|
||||||
if r.db_list().contains(dbname).run(conn):
|
if r.db_list().contains(dbname).run(conn):
|
||||||
raise DatabaseAlreadyExistsException('Database `{}` already exists'.format(dbname))
|
raise exceptions.DatabaseAlreadyExistsException('Database `{}` already exists'.format(dbname))
|
||||||
|
|
||||||
logger.info('Create:')
|
logger.info('Create:')
|
||||||
logger.info(' - database `%s`', dbname)
|
logger.info(' - database `%s`', dbname)
|
||||||
|
@ -19,3 +19,6 @@ class InvalidHash(Exception):
|
|||||||
class InvalidSignature(Exception):
|
class InvalidSignature(Exception):
|
||||||
"""Raised if there was an error checking the signature for a particular operation"""
|
"""Raised if there was an error checking the signature for a particular operation"""
|
||||||
|
|
||||||
|
class DatabaseAlreadyExistsException(Exception):
|
||||||
|
"""Raised when trying to create the database but the db is already there"""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user