error.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //! SQLite Database Error
  2. use thiserror::Error;
  3. /// SQLite Database Error
  4. #[derive(Debug, Error)]
  5. pub enum Error {
  6. /// SQLX Error
  7. #[error(transparent)]
  8. SQLX(#[from] sqlx::Error),
  9. /// NUT00 Error
  10. #[error(transparent)]
  11. CDKNUT00(#[from] cdk_common::nuts::nut00::Error),
  12. /// NUT01 Error
  13. #[error(transparent)]
  14. CDKNUT01(#[from] cdk_common::nuts::nut01::Error),
  15. /// NUT02 Error
  16. #[error(transparent)]
  17. CDKNUT02(#[from] cdk_common::nuts::nut02::Error),
  18. /// NUT04 Error
  19. #[error(transparent)]
  20. CDKNUT04(#[from] cdk_common::nuts::nut04::Error),
  21. /// NUT05 Error
  22. #[error(transparent)]
  23. CDKNUT05(#[from] cdk_common::nuts::nut05::Error),
  24. /// NUT07 Error
  25. #[error(transparent)]
  26. CDKNUT07(#[from] cdk_common::nuts::nut07::Error),
  27. /// Secret Error
  28. #[error(transparent)]
  29. CDKSECRET(#[from] cdk_common::secret::Error),
  30. /// BIP32 Error
  31. #[error(transparent)]
  32. BIP32(#[from] bitcoin::bip32::Error),
  33. /// Mint Url Error
  34. #[error(transparent)]
  35. MintUrl(#[from] cdk_common::mint_url::Error),
  36. /// Could Not Initialize Database
  37. #[error("Could not initialize database")]
  38. CouldNotInitialize,
  39. /// Invalid Database Path
  40. #[error("Invalid database path")]
  41. InvalidDbPath,
  42. /// Serde Error
  43. #[error(transparent)]
  44. Serde(#[from] serde_json::Error),
  45. }
  46. impl From<Error> for cdk_common::database::Error {
  47. fn from(e: Error) -> Self {
  48. Self::Database(Box::new(e))
  49. }
  50. }