Expand description
Error types for near-kit.
This module provides comprehensive error types for all near-kit operations.
§Error Hierarchy
Error— Main error type, returned by most operationsRpcError— RPC-specific errors (network, account not found, etc.)ParseAccountIdError— Invalid account ID formatParseAmountError— Invalid NEAR amount formatParseGasError— Invalid gas formatParseKeyError— Invalid key formatSignerError— Signing operation failuresKeyStoreError— Credential loading failures
§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
- KeyStore
Error - Error during keystore operations.
- Parse
Account IdError - Error parsing an account ID.
- Parse
Amount Error - Error parsing a NEAR token amount.
- Parse
GasError - Error parsing a gas value.
- Parse
Hash Error - Error parsing a crypto hash.
- Parse
KeyError - Error parsing a public or secret key.
- RpcError
- RPC-specific errors.
- Signer
Error - Error during signing operations.