Skip to main content

Module error

Module error 

Source
Expand description

Error types for near-kit.

This module provides comprehensive error types for all near-kit operations.

§Error Hierarchy

§Error Handling Examples

§Pattern Matching on RPC Errors

use near_kit::*;

let near = Near::testnet().build();

match near.balance("maybe-exists.testnet").await {
    Ok(balance) => println!("Balance: {}", balance.available),
    Err(Error::Rpc(RpcError::AccountNotFound(account))) => {
        println!("Account {} doesn't exist", account);
    }
    Err(e) => return Err(e),
}

§Checking Retryable Errors

use near_kit::RpcError;

fn should_retry(err: &RpcError) -> bool {
    err.is_retryable()
}

Enums§

Error
KeyStoreError
Error during keystore operations.
ParseAccountIdError
Error parsing an account ID.
ParseAmountError
Error parsing a NEAR token amount.
ParseGasError
Error parsing a gas value.
ParseHashError
Error parsing a crypto hash.
ParseKeyError
Error parsing a public or secret key.
RpcError
RPC-specific errors.
SignerError
Error during signing operations.