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    /// No route found
34    #[error("No route found")]
35    NoRoute,
36    /// Amount overflow
37    #[error("Amount overflow")]
38    AmountOverflow,
39    /// Errors coming from the backend
40    #[error("LND error: `{0}`")]
41    LndError(Status),
42    /// Errors invalid config
43    #[error("LND invalid config: `{0}`")]
44    InvalidConfig(String),
45    /// Could not read file
46    #[error("Could not read file")]
47    ReadFile,
48    /// Database Error
49    #[error("Database error: {0}")]
50    Database(String),
51}
52
53impl From<Error> for cdk_common::payment::Error {
54    fn from(e: Error) -> Self {
55        Self::Lightning(Box::new(e))
56    }
57}