Merge pull request #22 from bigchaindb/move-db-exception-to-the-right-module

Move db exception to the right module
This commit is contained in:
Sylvain Bellemare 2016-02-12 20:25:22 +01:00
commit 34e1507575
2 changed files with 5 additions and 4 deletions

View File

@ -5,13 +5,11 @@ import logging
import rethinkdb as r
import bigchaindb
from bigchaindb import exceptions
logger = logging.getLogger(__name__)
class DatabaseAlreadyExistsException(Exception):
pass
def get_conn():
'''Get the connection to the database.'''
@ -24,7 +22,7 @@ def init():
dbname = bigchaindb.config['database']['name']
if r.db_list().contains(dbname).run(conn):
raise DatabaseAlreadyExistsException('Database `{}` already exists'.format(dbname))
raise exceptions.DatabaseAlreadyExists('Database `{}` already exists'.format(dbname))
logger.info('Create:')
logger.info(' - database `%s`', dbname)

View File

@ -19,3 +19,6 @@ class InvalidHash(Exception):
class InvalidSignature(Exception):
"""Raised if there was an error checking the signature for a particular operation"""
class DatabaseAlreadyExists(Exception):
"""Raised when trying to create the database but the db is already there"""