[][src]Enum ckb_rpc::RPCError

pub enum RPCError {
    CKBInternalError,
    Deprecated,
    Invalid,
    RPCModuleIsDisabled,
    DaoError,
    IntegerOverflow,
    ConfigError,
    P2PFailedToBroadcast,
    DatabaseError,
    ChainIndexIsInconsistent,
    DatabaseIsCorrupt,
    TransactionFailedToResolve,
    TransactionFailedToVerify,
    AlertFailedToVerifySignatures,
    PoolRejectedTransactionByOutputsValidator,
    PoolRejectedTransactionByIllTransactionChecker,
    PoolRejectedTransactionByMinFeeRate,
    PoolRejectedTransactionByMaxAncestorsCountLimit,
    PoolIsFull,
    PoolRejectedDuplicatedTransaction,
    PoolRejectedMalformedTransaction,
}

CKB RPC error codes.

CKB RPC follows the JSON RPC specification about the error object.

Besides the pre-defined errors, all CKB defined errors are listed here.

Here is a reference to the pre-defined errors:

codemessagemeaning
-32700Parse errorInvalid JSON was received by the server.
-32600Invalid RequestThe JSON sent is not a valid Request object.
-32601Method not foundThe method does not exist / is not available.
-32602Invalid paramsInvalid method parameter(s).
-32603Internal errorInternal JSON-RPC error.
-32000 to -32099Server errorReserved for implementation-defined server-errors.

CKB application-defined errors follow some patterns to assign the codes:

  • -1 ~ -999 are general errors
  • -1000 ~ -2999 are module-specific errors. Each module generally gets 100 reserved error codes.

Unless otherwise noted, all the errors return optional detailed information as string in the error object data field.

Variants

CKBInternalError

(-1): CKB internal errors are considered to never happen or only happen when the system resources are exhausted.

Deprecated

(-2): The CKB method has been deprecated and disabled.

Set rpc.enable_deprecated_rpc to true in the config file to enable all deprecated methods.

Invalid

(-3): Error code -3 is no longer used.

Before v0.35.0, CKB returns all RPC errors using the error code -3. CKB no longer uses -3 since v0.35.0.

RPCModuleIsDisabled

(-4): The RPC method is not enabled.

CKB groups RPC methods into modules, and a method is enabled only when the module is explicitly enabled in the config file.

DaoError

(-5): DAO related errors.

IntegerOverflow

(-6): Integer operation overflow.

ConfigError

(-7): The error is caused by a config file option.

Users have to edit the config file to fix the error.

P2PFailedToBroadcast

(-101): The CKB local node failed to broadcast a message to its peers.

DatabaseError

(-200): Internal database error.

The CKB node persists data to the database. This is the error from the underlying database module.

ChainIndexIsInconsistent

(-201): The chain index is inconsistent.

An example of an inconsistent index is that the chain index says a block hash is in the chain but the block cannot be read from the database.

This is a fatal error usually due to a serious bug. Please back up the data directory and re-sync the chain from scratch.

DatabaseIsCorrupt

(-202): The underlying database is corrupt.

This is a fatal error usually caused by the underlying database used by CKB. Please back up the data directory and re-sync the chain from scratch.

TransactionFailedToResolve

(-301): Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.

TransactionFailedToVerify

(-302): Failed to verify the transaction.

AlertFailedToVerifySignatures

(-1000): Some signatures in the submit alert are invalid.

PoolRejectedTransactionByOutputsValidator

(-1102): The transaction is rejected by the outputs validator specified by the RPC parameter.

PoolRejectedTransactionByIllTransactionChecker

(-1103): Pool rejects some transactions which seem contain invalid VM instructions. See the issue link in the error message for details.

PoolRejectedTransactionByMinFeeRate

(-1104): The transaction fee rate must be greater than or equal to the config option tx_pool.min_fee_rate

The fee rate is calculated as:

fee / (1000 * tx_serialization_size_in_block_in_bytes)
PoolRejectedTransactionByMaxAncestorsCountLimit

(-1105): The in-pool ancestors count must be less than or equal to the config option tx_pool.max_ancestors_count

Pool rejects a large package of chained transactions to avoid certain kinds of DoS attacks.

PoolIsFull

(-1106): The transaction is rejected because the pool has reached its limit.

PoolRejectedDuplicatedTransaction

(-1107): The transaction is already in the pool.

PoolRejectedMalformedTransaction

(-1108): The transaction is rejected because it does not make sense in the context.

For example, a cellbase transaction is not allowed in send_transaction RPC.

Implementations

impl RPCError[src]

pub fn invalid_params<T: Display>(message: T) -> Error[src]

pub fn custom<T: Display>(error_code: RPCError, message: T) -> Error[src]

pub fn custom_with_data<T: Display, F: Debug>(
    error_code: RPCError,
    message: T,
    data: F
) -> Error
[src]

pub fn custom_with_error<T: Display + Debug>(
    error_code: RPCError,
    err: T
) -> Error
[src]

pub fn from_submit_transaction_reject(reject: &Reject) -> Error[src]

pub fn downcast_submit_transaction_reject(err: &CKBError) -> Option<&Reject>[src]

pub fn from_ckb_error(err: CKBError) -> Error[src]

pub fn from_failure_error(err: Error) -> Error[src]

pub fn ckb_internal_error<T: Display + Debug>(err: T) -> Error[src]

pub fn rpc_module_is_disabled(module: &str) -> Error[src]

pub fn rpc_method_is_deprecated() -> Error[src]

Trait Implementations

impl Clone for RPCError[src]

impl Copy for RPCError[src]

impl Debug for RPCError[src]

impl PartialEq<RPCError> for RPCError[src]

impl StructuralPartialEq for RPCError[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsAny for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,