error.rs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //! LDK Node Errors
  2. use thiserror::Error;
  3. /// LDK Node Error
  4. #[derive(Debug, Error)]
  5. pub enum Error {
  6. /// LDK Node error
  7. #[error("LDK Node error: {0}")]
  8. LdkNode(#[from] ldk_node::NodeError),
  9. /// LDK Build error
  10. #[error("LDK Build error: {0}")]
  11. LdkBuild(#[from] ldk_node::BuildError),
  12. /// Invalid description
  13. #[error("Invalid description")]
  14. InvalidDescription,
  15. /// Invalid payment hash
  16. #[error("Invalid payment hash")]
  17. InvalidPaymentHash,
  18. /// Invalid payment hash length
  19. #[error("Invalid payment hash length")]
  20. InvalidPaymentHashLength,
  21. /// Invalid payment ID length
  22. #[error("Invalid payment ID length")]
  23. InvalidPaymentIdLength,
  24. /// Unknown invoice amount
  25. #[error("Unknown invoice amount")]
  26. UnknownInvoiceAmount,
  27. /// Could not send bolt11 payment
  28. #[error("Could not send bolt11 payment")]
  29. CouldNotSendBolt11,
  30. /// Could not send bolt11 without amount
  31. #[error("Could not send bolt11 without amount")]
  32. CouldNotSendBolt11WithoutAmount,
  33. /// Payment not found
  34. #[error("Payment not found")]
  35. PaymentNotFound,
  36. /// Could not get amount spent
  37. #[error("Could not get amount spent")]
  38. CouldNotGetAmountSpent,
  39. /// Could not get payment amount
  40. #[error("Could not get payment amount")]
  41. CouldNotGetPaymentAmount,
  42. /// Unexpected payment kind
  43. #[error("Unexpected payment kind")]
  44. UnexpectedPaymentKind,
  45. /// Unsupported payment identifier type
  46. #[error("Unsupported payment identifier type")]
  47. UnsupportedPaymentIdentifierType,
  48. /// Invalid payment direction
  49. #[error("Invalid payment direction")]
  50. InvalidPaymentDirection,
  51. /// Hex decode error
  52. #[error("Hex decode error: {0}")]
  53. HexDecode(#[from] cdk_common::util::hex::Error),
  54. /// JSON error
  55. #[error("JSON error: {0}")]
  56. Json(#[from] serde_json::Error),
  57. /// Amount conversion error
  58. #[error("Amount conversion error: {0}")]
  59. AmountConversion(#[from] cdk_common::amount::Error),
  60. /// Invalid hex
  61. #[error("Invalid hex")]
  62. InvalidHex,
  63. }
  64. impl From<Error> for cdk_common::payment::Error {
  65. fn from(e: Error) -> Self {
  66. Self::Lightning(Box::new(e))
  67. }
  68. }