Exceptions

List of exceptions that library can produce.

Exception definitions.

ClientException

Bases: DogecoinException

P2P network error. This exception is never raised but functions as a superclass for other P2P client exceptions.

Source code in dogecoinrpc/exceptions.py
class ClientException(DogecoinException):
    """
    P2P network error.
    This exception is never raised but functions as a superclass
    for other P2P client exceptions.
    """

DogecoinException

Bases: Exception

Base class for exceptions received from Dogecoin server.

  • code -- Error code from dogecoind.
Source code in dogecoinrpc/exceptions.py
class DogecoinException(Exception):
    """
    Base class for exceptions received from Dogecoin server.

    - *code* -- Error code from ``dogecoind``.
    """

    # Standard JSON-RPC 2.0 errors
    INVALID_REQUEST = (-32600,)
    METHOD_NOT_FOUND = (-32601,)
    INVALID_PARAMS = (-32602,)
    INTERNAL_ERROR = (-32603,)
    PARSE_ERROR = (-32700,)

    # General application defined errors
    MISC_ERROR = -1  # std::exception thrown in command handling
    FORBIDDEN_BY_SAFE_MODE = (
        -2
    )  # Server is in safe mode, and command is not allowed in safe mode
    TYPE_ERROR = -3  # Unexpected type was passed as parameter
    INVALID_ADDRESS_OR_KEY = -5  # Invalid address or key
    OUT_OF_MEMORY = -7  # Ran out of memory during operation
    INVALID_PARAMETER = -8  # Invalid, missing or duplicate parameter
    DATABASE_ERROR = -20  # Database error
    DESERIALIZATION_ERROR = -22  # Error parsing or validating structure in raw format

    # P2P client errors
    CLIENT_NOT_CONNECTED = -9  # Dogecoin is not connected
    CLIENT_IN_INITIAL_DOWNLOAD = -10  # Still downloading initial blocks

    # Wallet errors
    WALLET_ERROR = -4  # Unspecified problem with wallet (key not found etc.)
    WALLET_INSUFFICIENT_FUNDS = -6  # Not enough funds in wallet or account
    WALLET_INVALID_ACCOUNT_NAME = -11  # Invalid account name
    WALLET_KEYPOOL_RAN_OUT = -12  # Keypool ran out, call keypoolrefill first
    WALLET_UNLOCK_NEEDED = (
        -13
    )  # Enter the wallet passphrase with walletpassphrase first
    WALLET_PASSPHRASE_INCORRECT = -14  # The wallet passphrase entered was incorrect
    WALLET_WRONG_ENC_STATE = -15  # Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.)
    WALLET_ENCRYPTION_FAILED = -16  # Failed to encrypt the wallet
    WALLET_ALREADY_UNLOCKED = -17  # Wallet is already unlocked

    def __init__(self, error):
        Exception.__init__(self, error["message"])
        self.code = error["code"]

DownloadingBlocks

Bases: ClientException

Client is still downloading blocks.

Source code in dogecoinrpc/exceptions.py
class DownloadingBlocks(ClientException):
    """
    Client is still downloading blocks.
    """

InsufficientFunds

Bases: WalletError

Insufficient funds to complete transaction in wallet or account

Source code in dogecoinrpc/exceptions.py
class InsufficientFunds(WalletError):
    """
    Insufficient funds to complete transaction in wallet or account
    """

InvalidAccountName

Bases: WalletError

Invalid account name

Source code in dogecoinrpc/exceptions.py
class InvalidAccountName(WalletError):
    """
    Invalid account name
    """

InvalidAddressOrKey

Bases: DogecoinException

Invalid address or key.

Source code in dogecoinrpc/exceptions.py
class InvalidAddressOrKey(DogecoinException):
    """
    Invalid address or key.
    """

InvalidParameter

Bases: DogecoinException

Invalid parameter provided to RPC call.

Source code in dogecoinrpc/exceptions.py
class InvalidParameter(DogecoinException):
    """
    Invalid parameter provided to RPC call.
    """

JSONTypeError

Bases: DogecoinException

Unexpected type was passed as parameter

Source code in dogecoinrpc/exceptions.py
class JSONTypeError(DogecoinException):
    """
    Unexpected type was passed as parameter
    """

KeypoolRanOut

Bases: WalletError

Keypool ran out, call keypoolrefill first

Source code in dogecoinrpc/exceptions.py
class KeypoolRanOut(WalletError):
    """
    Keypool ran out, call keypoolrefill first
    """

NotConnected

Bases: ClientException

Not connected to any peers.

Source code in dogecoinrpc/exceptions.py
class NotConnected(ClientException):
    """
    Not connected to any peers.
    """

OutOfMemory

Bases: DogecoinException

Out of memory during operation.

Source code in dogecoinrpc/exceptions.py
class OutOfMemory(DogecoinException):
    """
    Out of memory during operation.
    """

SafeMode

Bases: DogecoinException

Operation denied in safe mode (run dogecoind with -disablesafemode).

Source code in dogecoinrpc/exceptions.py
class SafeMode(DogecoinException):
    """
    Operation denied in safe mode (run ``dogecoind`` with ``-disablesafemode``).
    """

TransportException

Bases: Exception

Class to define transport-level failures.

Source code in dogecoinrpc/exceptions.py
class TransportException(Exception):
    """
    Class to define transport-level failures.
    """

    def __init__(self, msg, code=None, protocol=None, raw_detail=None):
        self.msg = msg
        self.code = code
        self.protocol = protocol
        self.raw_detail = raw_detail
        self.s = """
        Transport-level failure: {msg}
        Code: {code}
        Protocol: {protocol}
        """.format(msg=msg, code=code, protocol=protocol)

    def __str__(self):
        return self.s

WalletAlreadyUnlocked

Bases: WalletError

Wallet is already unlocked

Source code in dogecoinrpc/exceptions.py
class WalletAlreadyUnlocked(WalletError):
    """
    Wallet is already unlocked
    """

WalletEncryptionFailed

Bases: WalletError

Failed to encrypt the wallet

Source code in dogecoinrpc/exceptions.py
class WalletEncryptionFailed(WalletError):
    """
    Failed to encrypt the wallet
    """

WalletError

Bases: DogecoinException

Unspecified problem with wallet (key not found etc.)

Source code in dogecoinrpc/exceptions.py
class WalletError(DogecoinException):
    """
    Unspecified problem with wallet (key not found etc.)
    """

WalletPassphraseIncorrect

Bases: WalletError

The wallet passphrase entered was incorrect

Source code in dogecoinrpc/exceptions.py
class WalletPassphraseIncorrect(WalletError):
    """
    The wallet passphrase entered was incorrect
    """

WalletUnlockNeeded

Bases: WalletError

Enter the wallet passphrase with walletpassphrase first

Source code in dogecoinrpc/exceptions.py
class WalletUnlockNeeded(WalletError):
    """
    Enter the wallet passphrase with walletpassphrase first
    """

WalletWrongEncState

Bases: WalletError

Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.)

Source code in dogecoinrpc/exceptions.py
class WalletWrongEncState(WalletError):
    """
    Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.)
    """

wrap_exception(error)

Convert a JSON error object to a more specific Dogecoin exception.

Source code in dogecoinrpc/exceptions.py
def wrap_exception(error):
    """
    Convert a JSON error object to a more specific Dogecoin exception.
    """
    # work around to temporarily fix https://github.com/bitcoin/bitcoin/issues/3007
    if (
        error["code"] == DogecoinException.WALLET_ERROR
        and error["message"] == "Insufficient funds"
    ):
        error["code"] = DogecoinException.WALLET_INSUFFICIENT_FUNDS
    return _exception_map.get(error["code"], DogecoinException)(error)