mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add a new exception for MongoDB Authentication errors
This commit is contained in:
parent
0edb1c18f2
commit
9c4b284db9
@ -9,6 +9,10 @@ class ConnectionError(BackendError):
|
||||
"""Exception raised when the connection to the backend fails."""
|
||||
|
||||
|
||||
class AuthenticationError(ConnectionError):
|
||||
"""Exception raised when MongoDB Authentication fails"""
|
||||
|
||||
|
||||
class OperationError(BackendError):
|
||||
"""Exception raised when a backend operation fails."""
|
||||
|
||||
|
@ -8,7 +8,8 @@ from bigchaindb.utils import Lazy
|
||||
from bigchaindb.common.exceptions import ConfigurationError
|
||||
from bigchaindb.backend.exceptions import (DuplicateKeyError,
|
||||
OperationError,
|
||||
ConnectionError)
|
||||
ConnectionError,
|
||||
AuthenticationError)
|
||||
from bigchaindb.backend.connection import Connection
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -83,6 +84,8 @@ class MongoDBConnection(Connection):
|
||||
# `initialize_replica_set` might raise `ConnectionFailure` or `OperationFailure`.
|
||||
except (pymongo.errors.ConnectionFailure,
|
||||
pymongo.errors.OperationFailure) as exc:
|
||||
if "Authentication fail" in str(exc):
|
||||
raise AuthenticationError() from exc
|
||||
raise ConnectionError() from exc
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user