Error Handling and Migrate Function

Local Error Types

To create a new error type, you can use the error.rs file as in any Cosmwasm contract. Since our ADO template implements a lot of functionality imported by the andromeda-std crate, we will need to wrap the andromeda error types to be included in our error.rs file.

In the error.rs file include the following:

use andromeda_std::error::ContractError as AndrContractError;

Then we wrap it into our ContractError enum like so:

pub enum ContractError {
    #[error("{0}")]
    Std(#[from] StdError),

    #[error("{0}")]
    Andr(#[from] AndrContractError),
        .
        .
        .
    }
circle-info

This is present by default in our templatearrow-up-right.

Migrate Function

All our ADOs contain the following migrate function to be able to migrate an ADO to a new code_id:

circle-info

This will be added to our template, but if not found at the time you go through this, make sure to add it.

This can be imported and added into your ADO like so:

Last updated

Was this helpful?