ape.exceptions
- exception ape.exceptions.APINotImplementedError
Bases:
ApeException
,NotImplementedError
An error raised when an API class does not implement an abstract method.
- exception ape.exceptions.Abort(message: str | None = None)
Bases:
ClickException
A wrapper around a CLI exception. When you raise this error, the error is nicely printed to the terminal. This is useful for all user-facing errors.
- show(file=None)
Override default
show
to print CLI errors in red text.
- exception ape.exceptions.AccountsError
Bases:
ApeException
Raised when a problem occurs when using accounts.
- exception ape.exceptions.AliasAlreadyInUseError(alias: str)
Bases:
AccountsError
Raised when attempting to add an account using an alias that already maps to another account.
- exception ape.exceptions.ApeAttributeError
Bases:
ProjectError
,AttributeError
Raised when trying to access items via
.
access.
- exception ape.exceptions.ApeException
Bases:
Exception
An exception raised by ape.
- exception ape.exceptions.ApeIndexError
Bases:
ApeException
,IndexError
An exception that is also an IndexError. Useful for nicely displaying IndexErrors.
- exception ape.exceptions.ArgumentsLengthError(arguments_length: int, inputs: MethodABI | ConstructorABI | int | list | None = None, **kwargs)
Bases:
ContractDataError
Raised when calling a contract method with the wrong number of arguments.
- exception ape.exceptions.BlockNotFoundError(block_id: BlockID, reason: str | None = None)
Bases:
ProviderError
Raised when unable to find a block.
- exception ape.exceptions.ChainError
Bases:
ApeException
Raised when problems occur in the
ChainManager
.
- exception ape.exceptions.CompilerError
Bases:
ApeException
Raised when unable to compile.
- exception ape.exceptions.ConfigError
Bases:
ApeException
Raised when a problem occurs from the configuration file.
- exception ape.exceptions.ContractDataError
Bases:
ApeException
Raised when issues occur with local contract. NOTE: This error has nothing to do with on-chain contract logic errors; it is more about ABI-related issues and alike.
- exception ape.exceptions.ContractLogicError(revert_message: str | None = None, txn: TransactionAPI | ReceiptAPI | None = None, trace: TraceAPI | Callable[[], TraceAPI | None] | None = None, contract_address: AddressType | None = None, source_traceback: SourceTraceback | Callable[[], SourceTraceback | None] | None = None, base_err: Exception | None = None, project: ProjectManager | None = None, set_ape_traceback: bool = True)
Bases:
VirtualMachineError
Raised when there is a contract-defined revert, such as from an assert/require statement.
- property dev_message: str | None
The dev-string message of the exception.
- Raises:
ValueError – When unable to get dev message.
- classmethod from_error(err: Exception)
Creates this class from the error message of the given error.
This should be overridden whenever possible to handle provider-specific use-cases for raising this error.
- exception ape.exceptions.ContractNotFoundError(address: AddressType, has_explorer: bool, network_choice: str)
Bases:
ChainError
Raised when a contract is not found at an address.
- exception ape.exceptions.ConversionError
Bases:
ApeException
Raised when unable to convert a value.
- exception ape.exceptions.CustomError(abi: ErrorABI, inputs: dict[str, Any], txn: TransactionAPI | ReceiptAPI | None = None, trace: TraceAPI | Callable[[], TraceAPI | None] | None = None, contract_address: AddressType | None = None, base_err: Exception | None = None, source_traceback: SourceTraceback | Callable[[], SourceTraceback | None] | None = None)
Bases:
ContractLogicError
An error defined in a smart contract.
- property name: str
The name of the error.
- exception ape.exceptions.DecodingError(message: str | None = None)
Bases:
ContractDataError
Raised when issues occur while decoding data from a contract call, transaction, or event.
- exception ape.exceptions.EcosystemNotFoundError(ecosystem: str, options: Collection[str] | None = None)
Bases:
NetworkError
Raised when the ecosystem with the given name was not found.
- exception ape.exceptions.MethodNonPayableError
Bases:
ContractDataError
Raises when sending funds to a non-payable method
- exception ape.exceptions.MissingDeploymentBytecodeError(contract_type: ContractType)
Bases:
ContractDataError
Raised when trying to deploy an interface or empty data.
- exception ape.exceptions.NetworkError
Bases:
ApeException
Raised when a problem occurs when using blockchain networks.
- exception ape.exceptions.NetworkMismatchError(chain_id: int, network: NetworkAPI)
Bases:
ProviderError
Raised when connecting a provider to the wrong network.
- exception ape.exceptions.NetworkNotFoundError(network: str, ecosystem: str | None = None, options: Collection[str] | None = None)
Bases:
NetworkError
Raised when the network with the given name was not found.
- exception ape.exceptions.OutOfGasError(code: int | None = None, txn: TransactionAPI | ReceiptAPI | None = None, base_err: Exception | None = None, set_ape_traceback: bool = False)
Bases:
VirtualMachineError
Raised when detecting a transaction failed because it ran out of gas.
- exception ape.exceptions.PluginInstallError
Bases:
ApeException
An error to use when installing a plugin fails.
- exception ape.exceptions.PluginVersionError(operation: str, reason: str | None = None, resolution: str | None = None)
Bases:
PluginInstallError
An error related to specified plugin version.
- exception ape.exceptions.ProjectError
Bases:
ApeException
Raised when problems occur in a project.
- exception ape.exceptions.ProviderError
Bases:
ApeException
Raised when a problem occurs when using providers.
- exception ape.exceptions.ProviderNotConnectedError
Bases:
ProviderError
Raised when not connected to a provider.
- exception ape.exceptions.ProviderNotFoundError(provider: str, network: str | None = None, ecosystem: str | None = None, options: Collection[str] | None = None)
Bases:
NetworkError
Raised when the provider with the given name was not found.
- exception ape.exceptions.QueryEngineError
Bases:
ApeException
Raised when issues occur in a query engine.
- exception ape.exceptions.RPCTimeoutError(provider: SubprocessProvider, seconds: int | None = None, exception: Exception | None = None, *args, **kwargs)
Bases:
SubprocessTimeoutError
- exception ape.exceptions.SignatureError
Bases:
AccountsError
Raised when there are issues with signing.
- exception ape.exceptions.SubprocessError
Bases:
ApeException
An error raised whilst managing a subprocess.
- exception ape.exceptions.SubprocessTimeoutError(provider: SubprocessProvider, message: str | None = None, seconds: int | None = None, exception: Exception | None = None, *args, **kwargs)
Bases:
SubprocessError
A context-manager exception that raises if its operations exceed the given timeout seconds.
This implementation was inspired from py-geth.
- exception ape.exceptions.TransactionError(message: str | None = None, base_err: Exception | None = None, code: int | None = None, txn: TransactionAPI | ReceiptAPI | None = None, trace: TraceAPI | Callable[[], TraceAPI | None] | None = None, contract_address: AddressType | None = None, source_traceback: SourceTraceback | Callable[[], SourceTraceback | None] | None = None, project: ProjectManager | None = None, set_ape_traceback: bool = False)
Bases:
ApeException
Raised when issues occur related to transactions.
- exception ape.exceptions.TransactionNotFoundError(transaction_hash: str | None = None, error_message: str | None = None)
Bases:
ProviderError
Raised when unable to find a transaction.
- exception ape.exceptions.UnknownSnapshotError(snapshot_id: SnapshotID)
Bases:
ChainError
Raised when given an unknown snapshot ID.
- exception ape.exceptions.UnknownVersionError(version: str, name: str)
Bases:
ProjectError
Raised when trying to install an unknown version of a package.
- exception ape.exceptions.VirtualMachineError(message: str | None = None, base_err: Exception | None = None, code: int | None = None, txn: TransactionAPI | ReceiptAPI | None = None, trace: TraceAPI | Callable[[], TraceAPI | None] | None = None, contract_address: AddressType | None = None, source_traceback: SourceTraceback | Callable[[], SourceTraceback | None] | None = None, project: ProjectManager | None = None, set_ape_traceback: bool = False)
Bases:
TransactionError
Raised when a transaction error occurs in a virtual machine.
- ape.exceptions.handle_ape_exception(err: ApeException, base_paths: Iterable[Path | str]) bool
Handle a transaction error by showing relevant stack frames, including custom contract frames added to the exception. This method must be called within an
except
block or with an exception on the exc-stack.- Parameters:
err (
TransactionError
) – The transaction error being handled.base_paths (Optional[Iterable[Union[Path, str]]]) – Optionally include additional source-path prefixes to use when finding relevant frames.
- Returns:
True
if outputted something.- Return type:
bool