use axum::{
http::StatusCode,
response::{IntoResponse, Response},
};
use thiserror::Error;
#[derive(Error, Debug)]
pub(crate) enum KoerierError {
#[error("Error reading {0} from the file system")]
FsError(#[from] std::io::Error),
#[error("Error parsing PEM certificate")]
CertError(#[from] reqwest::Error),
#[error("Error fetching payment request from LND: {0}")]
Lnd(String),
#[error("Error opening image: {0}")]
Image(#[from] image::error::ImageError),
#[error("Error serializing into JSON: {0}")]
Json(#[from] serde_json::Error),
}
impl IntoResponse for KoerierError {
fn into_response(self) -> Response {
(StatusCode::INTERNAL_SERVER_ERROR, format!("{}", self)).into_response()
}
}