Trait oasis_contract_sdk::error::Error[][src]

pub trait Error: Error {
    fn module_name(&self) -> &str;
fn code(&self) -> u32; fn to_execution_result(&self) -> ExecutionResult { ... } }
Expand description

A contract error that gets propagated to the caller.

It extends std::error::Error with module name and error code so that errors can be easily serialized and transferred between different processes.

This trait can be derived:

#[derive(Clone, Debug, Error, thiserror::Error)]
enum Error {
   #[error("invalid argument")]
   InvalidArgument,          // autonumbered to 0

   #[sdk_error(code = 401)]  // manually numbered to 403 (`code` or autonumbering is required)

Required methods

Name of the module that emitted the error.

Error code uniquely identifying the error.

Provided methods

Converts the error into an execution result.

Implementations on Foreign Types