Skip to main content

cdk_lnd/
error.rs

1//! LND Errors
2
3use thiserror::Error;
4use tonic::Status;
5
6/// LND Error
7#[derive(Debug, Error)]
8pub enum Error {
9    /// Amount Error
10    #[error(transparent)]
11    Amount(#[from] cdk_common::amount::Error),
12    /// Invoice amount not defined
13    #[error("Unknown invoice amount")]
14    UnknownInvoiceAmount,
15    /// Unknown invoice
16    #[error("Unknown invoice")]
17    UnknownInvoice,
18    /// Connection error
19    #[error("LND connection error")]
20    Connection,
21    /// Invalid hash
22    #[error("Invalid hash")]
23    InvalidHash,
24    /// Payment failed
25    #[error("LND payment failed")]
26    PaymentFailed,
27    /// Unknown payment status
28    #[error("LND unknown payment status")]
29    UnknownPaymentStatus,
30    /// Missing last hop in route
31    #[error("LND missing last hop in route")]
32    MissingLastHop,
33    /// Amount overflow
34    #[error("Amount overflow")]
35    AmountOverflow,
36    /// Errors coming from the backend
37    #[error("LND error: `{0}`")]
38    LndError(Status),
39    /// Errors invalid config
40    #[error("LND invalid config: `{0}`")]
41    InvalidConfig(String),
42    /// Could not read file
43    #[error("Could not read file")]
44    ReadFile,
45    /// Database Error
46    #[error("Database error: {0}")]
47    Database(String),
48}
49
50impl From<Error> for cdk_common::payment::Error {
51    fn from(e: Error) -> Self {
52        Self::Lightning(Box::new(e))
53    }
54}