Macro anchor_lang::error

source ·
error!() { /* proc-macro */ }
Expand description

Generates an Error::AnchorError that includes file and line information.

Example

#[program]
mod errors {
    use super::*;
    pub fn example(_ctx: Context<Example>) -> Result<()> {
        Err(error!(MyError::Hello))
    }
}

#[error_code]
pub enum MyError {
    #[msg("This is an error message clients will automatically display")]
    Hello,
}