Source code for bittensor.errors

# The MIT License (MIT)
# Copyright © 2023 Opentensor Foundation

# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software.

# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from __future__ import annotations

import typing

if typing.TYPE_CHECKING:
    import bittensor


[docs] class ChainError(BaseException): r"""Base error for any chain related errors.""" pass
[docs] class ChainConnectionError(ChainError): r"""Error for any chain connection related errors.""" pass
[docs] class ChainTransactionError(ChainError): r"""Error for any chain transaction related errors.""" pass
[docs] class ChainQueryError(ChainError): r"""Error for any chain query related errors.""" pass
[docs] class StakeError(ChainTransactionError): r"""Error raised when a stake transaction fails.""" pass
[docs] class UnstakeError(ChainTransactionError): r"""Error raised when an unstake transaction fails.""" pass
[docs] class IdentityError(ChainTransactionError): r"""Error raised when an identity transaction fails.""" pass
[docs] class NominationError(ChainTransactionError): r"""Error raised when a nomination transaction fails.""" pass
[docs] class TakeError(ChainTransactionError): r"""Error raised when a increase / decrease take transaction fails.""" pass
[docs] class TransferError(ChainTransactionError): r"""Error raised when a transfer transaction fails.""" pass
[docs] class RegistrationError(ChainTransactionError): r"""Error raised when a neuron registration transaction fails.""" pass
[docs] class NotRegisteredError(ChainTransactionError): r"""Error raised when a neuron is not registered, and the transaction requires it to be.""" pass
[docs] class NotDelegateError(StakeError): r"""Error raised when a hotkey you are trying to stake to is not a delegate.""" pass
[docs] class KeyFileError(Exception): """Error thrown when the keyfile is corrupt, non-writable, non-readable or the password used to decrypt is invalid.""" pass
[docs] class MetadataError(ChainTransactionError): r"""Error raised when metadata commitment transaction fails.""" pass
[docs] class InvalidRequestNameError(Exception): r"""This exception is raised when the request name is invalid. Ususally indicates a broken URL.""" pass
[docs] class SynapseException(Exception): def __init__( self, message="Synapse Exception", synapse: "bittensor.Synapse" | None = None ): self.message = message self.synapse = synapse super().__init__(self.message)
[docs] class UnknownSynapseError(SynapseException): r"""This exception is raised when the request name is not found in the Axon's forward_fns dictionary.""" pass
[docs] class SynapseParsingError(Exception): r"""This exception is raised when the request headers are unable to be parsed into the synapse type.""" pass
[docs] class NotVerifiedException(SynapseException): r"""This exception is raised when the request is not verified.""" pass
[docs] class BlacklistedException(SynapseException): r"""This exception is raised when the request is blacklisted.""" pass
[docs] class PriorityException(SynapseException): r"""This exception is raised when the request priority is not met.""" pass
[docs] class PostProcessException(SynapseException): r"""This exception is raised when the response headers cannot be updated.""" pass
[docs] class RunException(SynapseException): r"""This exception is raised when the requested function cannot be executed. Indicates a server error.""" pass
[docs] class InternalServerError(SynapseException): r"""This exception is raised when the requested function fails on the server. Indicates a server error.""" pass
[docs] class SynapseDendriteNoneException(SynapseException): def __init__( self, message="Synapse Dendrite is None", synapse: "bittensor.Synapse" | None = None, ): self.message = message super().__init__(self.message, synapse)