use std::net::AddrParseError;
use reqwest::StatusCode;
use thiserror::Error;
#[derive(Error, Debug)]
#[error("Porkbun API error: {status} - {message}")]
pub struct ApiError {
status: StatusCode,
message: String,
}
impl ApiError {
pub(crate) fn new(status: StatusCode, message: Option<&str>) -> Self {
let message = message.unwrap_or("unable to get error message");
Self {
status,
message: message.to_owned(),
}
}
}
#[derive(Error, Debug)]
pub enum ClientError {
#[error(transparent)]
Porkbun(#[from] ApiError),
#[error(transparent)]
Reqwest(#[from] reqwest::Error),
#[error(transparent)]
UrlParse(#[from] url::ParseError),
}
#[derive(Error, Debug)]
pub enum ClientBuilderError {
#[error(transparent)]
UrlParse(#[from] url::ParseError),
}
#[derive(Error, Debug)]
pub enum ContentCreationError {
#[error(transparent)]
AddrParse(#[from] AddrParseError),
}