Inherit from BigchainDBError for common exceptions

This commit is contained in:
Sylvain Bellemare 2017-01-11 13:34:45 +01:00 committed by Sylvain Bellemare
parent fdf2a85c97
commit c036b1490b

View File

@ -1,28 +1,29 @@
"""Custom exceptions used in the `bigchaindb` package. """Custom exceptions used in the `bigchaindb` package.
""" """
from bigchaindb.exceptions import BigchainDBError
class ConfigurationError(Exception): class ConfigurationError(BigchainDBError):
"""Raised when there is a problem with server configuration""" """Raised when there is a problem with server configuration"""
class OperationError(Exception): class OperationError(BigchainDBError):
"""Raised when an operation cannot go through""" """Raised when an operation cannot go through"""
class TransactionDoesNotExist(Exception): class TransactionDoesNotExist(BigchainDBError):
"""Raised if the transaction is not in the database""" """Raised if the transaction is not in the database"""
class TransactionOwnerError(Exception): class TransactionOwnerError(BigchainDBError):
"""Raised if a user tries to transfer a transaction they don't own""" """Raised if a user tries to transfer a transaction they don't own"""
class DoubleSpend(Exception): class DoubleSpend(BigchainDBError):
"""Raised if a double spend is found""" """Raised if a double spend is found"""
class ValidationError(Exception): class ValidationError(BigchainDBError):
"""Raised if there was an error in validation""" """Raised if there was an error in validation"""
@ -35,56 +36,56 @@ class SchemaValidationError(ValidationError):
"""Raised if there was any error validating an object's schema""" """Raised if there was any error validating an object's schema"""
class InvalidSignature(Exception): class InvalidSignature(BigchainDBError):
"""Raised if there was an error checking the signature for a particular """Raised if there was an error checking the signature for a particular
operation""" operation"""
class DatabaseAlreadyExists(Exception): class DatabaseAlreadyExists(BigchainDBError):
"""Raised when trying to create the database but the db is already there""" """Raised when trying to create the database but the db is already there"""
class DatabaseDoesNotExist(Exception): class DatabaseDoesNotExist(BigchainDBError):
"""Raised when trying to delete the database but the db is not there""" """Raised when trying to delete the database but the db is not there"""
class KeypairNotFoundException(Exception): class KeypairNotFoundException(BigchainDBError):
"""Raised if operation cannot proceed because the keypair was not given""" """Raised if operation cannot proceed because the keypair was not given"""
class KeypairMismatchException(Exception): class KeypairMismatchException(BigchainDBError):
"""Raised if the private key(s) provided for signing don't match any of the """Raised if the private key(s) provided for signing don't match any of the
current owner(s)""" current owner(s)"""
class StartupError(Exception): class StartupError(BigchainDBError):
"""Raised when there is an error starting up the system""" """Raised when there is an error starting up the system"""
class ImproperVoteError(Exception): class ImproperVoteError(BigchainDBError):
"""Raised if a vote is not constructed correctly, or signed incorrectly""" """Raised if a vote is not constructed correctly, or signed incorrectly"""
class MultipleVotesError(Exception): class MultipleVotesError(BigchainDBError):
"""Raised if a voter has voted more than once""" """Raised if a voter has voted more than once"""
class GenesisBlockAlreadyExistsError(Exception): class GenesisBlockAlreadyExistsError(BigchainDBError):
"""Raised when trying to create the already existing genesis block""" """Raised when trying to create the already existing genesis block"""
class CyclicBlockchainError(Exception): class CyclicBlockchainError(BigchainDBError):
"""Raised when there is a cycle in the blockchain""" """Raised when there is a cycle in the blockchain"""
class TransactionNotInValidBlock(Exception): class TransactionNotInValidBlock(BigchainDBError):
"""Raised when a transfer transaction is attempting to fulfill the """Raised when a transfer transaction is attempting to fulfill the
outputs of a transaction that is in an invalid or undecided block""" outputs of a transaction that is in an invalid or undecided block"""
class AssetIdMismatch(Exception): class AssetIdMismatch(BigchainDBError):
"""Raised when multiple transaction inputs related to different assets""" """Raised when multiple transaction inputs related to different assets"""
class AmountError(Exception): class AmountError(BigchainDBError):
"""Raised when there is a problem with a transaction's output amounts""" """Raised when there is a problem with a transaction's output amounts"""