Function handle_result

Source
pub fn handle_result()
Expand description

Support Result types regardless of how they’re referred to inner #[near] annotation.

Have #[handle_result] to Support Result types regardless of how they’re referred to Function marked with #[handle_result] should return Result<T, E> (where E implements FunctionError). If you’re trying to use a type alias for Result, try #[handle_result(aliased)]

§Examples

§Basic example

use near_sdk::{near, AccountId, Promise, PromiseError};

#[near(contract_state)]
#[derive(Default)]
pub struct Counter {
    val: u64,
}

#[near]
impl Counter {
    #[handle_result]
    pub fn get_result(
        &self,
        account_id: AccountId,
        #[callback_result] set_status_result: Result<(), PromiseError>,
    ) -> Result<(), &'static str> {
        // ..
        Ok(())
    }
}