hamsando 0.2.1

A simple and type-safe client for the Porkbun API.
Documentation
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 {
    /// Creates a new `ApiError` from a status code and message.
    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),
}