Skip to main content

ErrorCode

Trait ErrorCode 

Source
pub trait ErrorCode:
    Debug
    + Display
    + Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn code(&self) -> i32;
    fn from_code(code: i32) -> Option<Self>
       where Self: Sized;
}
Expand description

Trait for defining module-specific error codes.

This trait should be implemented by enums that represent different error categories in greenlight. The error codes should be unique integers that can be serialized and transmitted over the network.

Required Methods§

Source

fn code(&self) -> i32

Returns the numeric error code for this error type.

This code should be unique within your application and stable across versions for backward compatibility.

Source

fn from_code(code: i32) -> Option<Self>
where Self: Sized,

Attempts to construct an error code from its numeric representation.

Returns None if the code is not recognized.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ErrorCode for ClnRpcError

Implementation of ErrorCode for CLN RPC errors.

This implementation treats all i32 values as valid error codes, allowing us to preserve any error code returned by CLN without loss.