1use std::string::FromUtf8Error;
2
3use lightning_invoice::ParseOrSemanticError;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum MokshaWalletError {
8 #[cfg(target_arch = "wasm32")]
9 #[error("GlooNetError - {0}")]
10 GlooNet(#[from] gloo_net::Error),
11
12 #[error("SerdeJsonError - {0}")]
13 Json(#[from] serde_json::Error),
14
15 #[cfg(not(target_arch = "wasm32"))]
16 #[error("ReqwestError - {0}")]
17 Reqwest(#[from] reqwest::Error),
18
19 #[cfg(not(target_arch = "wasm32"))]
20 #[error("InvalidHeaderValueError - {0}")]
21 InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue),
22 #[error("{0}")]
23 MintError(String),
24
25 #[error("{1}")]
26 InvoiceNotPaidYet(u64, String),
27
28 #[error("UnexpectedResponse - {0}")]
29 UnexpectedResponse(String),
30
31 #[error("MokshaCoreError - {0}")]
32 MokshaCore(#[from] moksha_core::error::MokshaCoreError),
33
34 #[cfg(not(target_arch = "wasm32"))]
35 #[error("DB Error {0}")]
36 Db(#[from] sqlx::Error),
37
38 #[cfg(not(target_arch = "wasm32"))]
39 #[error("Sqlite Error {0}")]
40 Sqlite(#[from] sqlx::sqlite::SqliteError),
41 #[error("Utf8 Error {0}")]
42 Utf8(#[from] FromUtf8Error),
43
44 #[error("Invalid Proofs")]
45 InvalidProofs,
46
47 #[error("Not enough tokens")]
48 NotEnoughTokens,
49
50 #[error("Failed to decode payment request {0} - Error {1}")]
51 DecodeInvoice(String, ParseOrSemanticError),
52
53 #[error("Invalid invoice {0}")]
54 InvalidInvoice(String),
55
56 #[error("URLParseError - {0}")]
57 Url(#[from] url::ParseError),
58
59 #[error("Unsupported version: Only mints with /v1 api are supported")]
60 UnsupportedApiVersion,
61}