Source code for bittensor.core.errors
# The MIT License (MIT)
# Copyright © 2024 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
from bittensor.core.synapse import Synapse
[docs]
class ChainError(BaseException):
"""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: "Synapse" | None = 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: "Synapse" | None = None,
):
self.message = message
super().__init__(self.message, synapse)