use crate::PaymentKind;
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
pub enum Error {
#[error("Expected payment kind {0:?}")]
ExpectedKind(PaymentKind),
#[error(
"Wrong Liquid address network, expected {expected} address",
expected = if *.expected_mainnet { "mainnet" } else { "testnet" }
)]
WrongLiquidNetwork { expected_mainnet: bool },
#[error("BIP353 did not resolve to a lightning offer")]
Bip353OfferNotFound,
#[error("Invalid schema: {0}")]
InvalidSchema(String),
#[error("HTTP request returned status {0}")]
HttpStatus(reqwest::StatusCode),
#[error("Reqwest error: {0}")]
Reqwest(String),
#[error("URL parse error: {0}")]
Url(String),
#[error("Amount overflow")]
AmountOverflow,
#[error("{0}")]
Generic(String),
}
impl From<String> for Error {
fn from(s: String) -> Self {
Self::Generic(s)
}
}
impl From<&str> for Error {
fn from(s: &str) -> Self {
Self::Generic(s.to_string())
}
}
impl From<reqwest::Error> for Error {
fn from(err: reqwest::Error) -> Self {
Self::Reqwest(err.to_string())
}
}
impl From<url::ParseError> for Error {
fn from(err: url::ParseError) -> Self {
Self::Url(err.to_string())
}
}