Enum ckb_rpc::RPCError

source ·
pub enum RPCError {
Show 26 variants CKBInternalError = -1, Deprecated = -2, Invalid = -3, RPCModuleIsDisabled = -4, DaoError = -5, IntegerOverflow = -6, ConfigError = -7, P2PFailedToBroadcast = -101, DatabaseError = -200, ChainIndexIsInconsistent = -201, DatabaseIsCorrupt = -202, TransactionFailedToResolve = -301, TransactionFailedToVerify = -302, AlertFailedToVerifySignatures = -1_000, PoolRejectedTransactionByOutputsValidator = -1_102, PoolRejectedTransactionByIllTransactionChecker = -1_103, PoolRejectedTransactionByMinFeeRate = -1_104, PoolRejectedTransactionByMaxAncestorsCountLimit = -1_105, PoolIsFull = -1_106, PoolRejectedDuplicatedTransaction = -1_107, PoolRejectedMalformedTransaction = -1_108, TransactionExpired = -1_109, PoolRejectedTransactionBySizeLimit = -1_110, PoolRejectedRBF = -1_111, PoolRejectedInvalidated = -1_112, Indexer = -1_200,
}
Expand description

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

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

§

Deprecated = -2

(-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

(-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

(-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

(-5): DAO related errors.

§

IntegerOverflow = -6

(-6): Integer operation overflow.

§

ConfigError = -7

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

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

§

P2PFailedToBroadcast = -101

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

§

DatabaseError = -200

(-200): Internal database error.

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

§

ChainIndexIsInconsistent = -201

(-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

(-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

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

§

TransactionFailedToVerify = -302

(-302): Failed to verify the transaction.

§

AlertFailedToVerifySignatures = -1_000

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

§

PoolRejectedTransactionByOutputsValidator = -1_102

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

§

PoolRejectedTransactionByIllTransactionChecker = -1_103

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

§

PoolRejectedTransactionByMinFeeRate = -1_104

(-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 = -1_105

(-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 = -1_106

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

§

PoolRejectedDuplicatedTransaction = -1_107

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

§

PoolRejectedMalformedTransaction = -1_108

(-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.

§

TransactionExpired = -1_109

(-1109): The transaction is expired from tx-pool after expiry_hours.

§

PoolRejectedTransactionBySizeLimit = -1_110

(-1110): The transaction exceeded maximum size limit.

§

PoolRejectedRBF = -1_111

(-1111): The transaction is rejected for RBF checking.

§

PoolRejectedInvalidated = -1_112

(-1112): The transaction is rejected for ref cell consuming.

§

Indexer = -1_200

(-1200): The indexer error.

Implementations§

source§

impl RPCError

source

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

Invalid method parameter(s).

source

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

Creates an RPC error with custom error code and message.

source

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

Creates an RPC error with custom error code, message and data.

source

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

Creates an RPC error from std error with the custom error code.

The parameter err is usually an std error. The Display form is used as the error message, and the Debug form is used as the data.

source

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

Creates an RPC error from the reason that a transaction is rejected to be submitted.

source

pub fn from_ckb_error(err: CKBError) -> Error

Creates an CKB error from CKBError.

source

pub fn from_any_error(err: AnyError) -> Error

Creates an RPC error from AnyError.

source

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

CKB internal error.

CKB internal errors are considered to never happen or only happen when the system resources are exhausted.

source

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

RPC error which indicates that the method is disabled.

RPC methods belong to modules and they are only enabled when the belonging module is included in the config.

source

pub fn rpc_method_is_deprecated() -> Error

RPC error which indicates that the method is deprecated.

Deprecated methods are disabled by default unless they are enabled via the config options enable_deprecated_rpc.

Trait Implementations§

source§

impl Clone for RPCError

source§

fn clone(&self) -> RPCError

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RPCError

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl JsonSchema for RPCError

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

impl PartialEq for RPCError

source§

fn eq(&self, other: &RPCError) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for RPCError

source§

impl Eq for RPCError

source§

impl StructuralPartialEq for RPCError

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Cast to trait Any
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more