bigchaindb/bigchaindb/common/exceptions.py

116 lines
3.2 KiB
Python
Raw Normal View History

# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB software contributors.
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
# Code is Apache-2.0 and docs are CC-BY-4.0
2016-08-17 14:48:10 +02:00
"""Custom exceptions used in the `bigchaindb` package.
"""
from bigchaindb.exceptions import BigchainDBError
2016-08-17 14:48:10 +02:00
class ConfigurationError(BigchainDBError):
2016-08-23 20:08:51 +02:00
"""Raised when there is a problem with server configuration"""
class DatabaseDoesNotExist(BigchainDBError):
"""Raised when trying to delete the database but the db is not there"""
2016-08-17 14:48:10 +02:00
class StartupError(BigchainDBError):
"""Raised when there is an error starting up the system"""
2016-08-17 14:48:10 +02:00
class CyclicBlockchainError(BigchainDBError):
"""Raised when there is a cycle in the blockchain"""
2016-08-17 14:48:10 +02:00
class KeypairMismatchException(BigchainDBError):
"""Raised if the private key(s) provided for signing don't match any of the
current owner(s)
"""
2016-08-17 14:48:10 +02:00
class OperationError(BigchainDBError):
"""Raised when an operation cannot go through"""
2016-08-17 14:48:10 +02:00
################################################################################
# Validation errors
#
# All validation errors (which are handleable errors, not faults) should
# subclass ValidationError. However, where possible they should also have their
# own distinct type to differentiate them from other validation errors,
# especially for the purposes of testing.
2016-08-17 14:48:10 +02:00
class ValidationError(BigchainDBError):
"""Raised if there was an error in validation"""
2016-08-17 14:48:10 +02:00
class DoubleSpend(ValidationError):
"""Raised if a double spend is found"""
2016-08-17 14:48:10 +02:00
class InvalidHash(ValidationError):
"""Raised if there was an error checking the hash for a particular
operation
"""
2016-08-17 14:48:10 +02:00
class SchemaValidationError(ValidationError):
"""Raised if there was any error validating an object's schema"""
2016-08-17 14:48:10 +02:00
class InvalidSignature(ValidationError):
"""Raised if there was an error checking the signature for a particular
operation
"""
2016-08-17 14:48:10 +02:00
class AssetIdMismatch(ValidationError):
2016-09-28 11:03:32 +02:00
"""Raised when multiple transaction inputs related to different assets"""
class AmountError(ValidationError):
"""Raised when there is a problem with a transaction's output amounts"""
class InputDoesNotExist(ValidationError):
"""Raised if a transaction input does not exist"""
class TransactionOwnerError(ValidationError):
"""Raised if a user tries to transfer a transaction they don't own"""
class DuplicateTransaction(ValidationError):
"""Raised if a duplicated transaction is found"""
class ThresholdTooDeep(ValidationError):
"""Raised if threshold condition is too deep"""
class MultipleValidatorOperationError(ValidationError):
"""Raised when a validator update pending but new request is submited"""
class MultipleInputsError(ValidationError):
"""Raised if there were multiple inputs when only one was expected"""
class InvalidProposer(ValidationError):
"""Raised if the public key is not a part of the validator set"""
class UnequalValidatorSet(ValidationError):
"""Raised if the validator sets differ"""
class InvalidPowerChange(ValidationError):
"""Raised if proposed power change in validator set is >=1/3 total power"""
class InvalidPublicKey(ValidationError):
"""Raised if public key doesn't match the encoding type"""