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:
code | message | meaning |
---|---|---|
-32700 | Parse error | Invalid JSON was received by the server. |
-32600 | Invalid Request | The JSON sent is not a valid Request object. |
-32601 | Method not found | The method does not exist / is not available. |
-32602 | Invalid params | Invalid method parameter(s). |
-32603 | Internal error | Internal JSON-RPC error. |
-32000 to -32099 | Server error | Reserved 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
impl RPCError
sourcepub fn invalid_params<T: Display>(message: T) -> Error
pub fn invalid_params<T: Display>(message: T) -> Error
Invalid method parameter(s).
sourcepub fn custom<T: Display>(error_code: RPCError, message: T) -> Error
pub fn custom<T: Display>(error_code: RPCError, message: T) -> Error
Creates an RPC error with custom error code and message.
sourcepub fn custom_with_data<T: Display, F: Debug>(
error_code: RPCError,
message: T,
data: F
) -> Error
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.
sourcepub fn custom_with_error<T: Display + Debug>(
error_code: RPCError,
err: T
) -> Error
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.
sourcepub fn from_submit_transaction_reject(reject: &Reject) -> Error
pub fn from_submit_transaction_reject(reject: &Reject) -> Error
Creates an RPC error from the reason that a transaction is rejected to be submitted.
sourcepub fn from_ckb_error(err: CKBError) -> Error
pub fn from_ckb_error(err: CKBError) -> Error
Creates an CKB error from CKBError
.
sourcepub fn from_any_error(err: AnyError) -> Error
pub fn from_any_error(err: AnyError) -> Error
Creates an RPC error from AnyError
.
sourcepub fn ckb_internal_error<T: Display + Debug>(err: T) -> Error
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.
sourcepub fn rpc_module_is_disabled(module: &str) -> Error
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.
sourcepub fn rpc_method_is_deprecated() -> Error
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 JsonSchema for RPCError
impl JsonSchema for RPCError
source§fn schema_name() -> String
fn schema_name() -> String
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moresource§impl PartialEq for RPCError
impl PartialEq for RPCError
impl Copy for RPCError
impl Eq for RPCError
impl StructuralPartialEq for RPCError
Auto Trait Implementations§
impl Freeze for RPCError
impl RefUnwindSafe for RPCError
impl Send for RPCError
impl Sync for RPCError
impl Unpin for RPCError
impl UnwindSafe for RPCError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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