Source code for bittensor.core.errors
from typing import Optional, TYPE_CHECKING
from async_substrate_interface.errors import (
SubstrateRequestException,
StorageFunctionNotFound,
BlockNotFound,
ExtrinsicNotFound,
)
if TYPE_CHECKING:
from bittensor.core.synapse import Synapse
# redundant aliases
SubstrateRequestException = SubstrateRequestException
StorageFunctionNotFound = StorageFunctionNotFound
BlockNotFound = BlockNotFound
ExtrinsicNotFound = ExtrinsicNotFound
[docs]
class MaxSuccessException(Exception):
"""Raised when the POW Solver has reached the max number of successful solutions."""
[docs]
class MaxAttemptsException(Exception):
"""Raised when the POW Solver has reached the max number of attempts."""
[docs]
class ChainError(SubstrateRequestException):
"""Base error for any chain related errors."""
[docs]
class ChainConnectionError(ChainError):
"""Error for any chain connection related errors."""
[docs]
class ChainTransactionError(ChainError):
"""Error for any chain transaction related errors."""
[docs]
class ChainQueryError(ChainError):
"""Error for any chain query related errors."""
[docs]
class StakeError(ChainTransactionError):
"""Error raised when a stake transaction fails."""
[docs]
class UnstakeError(ChainTransactionError):
"""Error raised when an unstake transaction fails."""
[docs]
class IdentityError(ChainTransactionError):
"""Error raised when an identity transaction fails."""
[docs]
class NominationError(ChainTransactionError):
"""Error raised when a nomination transaction fails."""
[docs]
class TakeError(ChainTransactionError):
"""Error raised when an increase / decrease take transaction fails."""
[docs]
class TransferError(ChainTransactionError):
"""Error raised when a transfer transaction fails."""
[docs]
class RegistrationError(ChainTransactionError):
"""Error raised when a neuron registration transaction fails."""
[docs]
class NotRegisteredError(ChainTransactionError):
"""Error raised when a neuron is not registered, and the transaction requires it to be."""
[docs]
class NotDelegateError(StakeError):
"""Error raised when a hotkey you are trying to stake to is not a delegate."""
[docs]
class InvalidRequestNameError(Exception):
"""This exception is raised when the request name is invalid. Usually indicates a broken URL."""
[docs]
class SynapseException(Exception):
def __init__(
self, message="Synapse Exception", synapse: Optional["Synapse"] = None
):
self.message = message
self.synapse = synapse
super().__init__(self.message)
[docs]
class UnknownSynapseError(SynapseException):
"""This exception is raised when the request name is not found in the Axon's forward_fns dictionary."""
[docs]
class SynapseParsingError(Exception):
"""This exception is raised when the request headers are unable to be parsed into the synapse type."""
[docs]
class NotVerifiedException(SynapseException):
"""This exception is raised when the request is not verified."""
[docs]
class BlacklistedException(SynapseException):
"""This exception is raised when the request is blacklisted."""
[docs]
class PriorityException(SynapseException):
"""This exception is raised when the request priority is not met."""
[docs]
class PostProcessException(SynapseException):
"""This exception is raised when the response headers cannot be updated."""
[docs]
class RunException(SynapseException):
"""This exception is raised when the requested function cannot be executed. Indicates a server error."""
[docs]
class InternalServerError(SynapseException):
"""This exception is raised when the requested function fails on the server. Indicates a server error."""
[docs]
class SynapseDendriteNoneException(SynapseException):
def __init__(
self,
message="Synapse Dendrite is None",
synapse: Optional["Synapse"] = None,
):
self.message = message
super().__init__(self.message, synapse)