use crate::BtChannelOrderErrorType;
use reqwest::Error as ReqwestError;
use thiserror::Error;
use url::ParseError;
pub const ERR_INIT_HTTP_CLIENT: &str = "Failed to initialize HTTP client";
pub const ERR_LSP_BALANCE_ZERO: &str = "lsp_balance_sat must be greater than 0";
pub const ERR_INVOICE_SAT_ZERO: &str = "invoice_sat must be greater than 0";
pub const ERR_NODE_ID_EMPTY: &str = "node_id cannot be empty";
pub const ERR_ORDER_ID_CONNECTION_EMPTY: &str =
"order_id and connection_string_or_pubkey cannot be empty";
pub const ERR_INVALID_REQUEST_PARAMS: &str = "Invalid request parameters";
pub const ERR_INVALID_REQUEST_FORMAT: &str = "Invalid request format";
#[derive(Error, Debug)]
pub enum BlocktankError {
#[error("HTTP client error: {0}")]
HttpClient(#[from] ReqwestError),
#[error("Client error: {0}")]
Client(String),
#[error("Blocktank error: {message} {data:?}")]
BlocktankClient {
message: String,
data: serde_json::Value,
},
#[error("URL parse error: {0}")]
UrlParse(#[from] ParseError),
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("Channel open error: {error_type:?} - {message}")]
ChannelOpen {
error_type: BtChannelOrderErrorType,
message: String,
},
#[error("Order state error: {message}")]
OrderState { message: String },
#[error("Invalid parameter: {message}")]
InvalidParameter { message: String },
#[error("Initialization error: {message}")]
InitializationError { message: String },
#[error("Blocktank API error: {message} {data:?}")]
Api {
message: String,
data: serde_json::Value,
},
#[error("Blocktank DataError: {error_details}")]
DataError { error_details: String },
}
pub type Result<T> = std::result::Result<T, BlocktankError>;