api_req 0.5.2

A library for making API requests with ease
Documentation
//! Error module

use core::error::Error;
use core::fmt;

/// Error type for API
#[derive(Debug)]
pub enum ApiErr {
    /// Reqwest error
    Reqwest(reqwest::Error),
    /// Serde error
    UnDeserializeable(String),
    /// Other errors
    Other(String),
}

impl From<reqwest::Error> for ApiErr {
    fn from(e: reqwest::Error) -> Self {
        Self::Reqwest(e)
    }
}

impl fmt::Display for ApiErr {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::Reqwest(e) => write!(f, "Reqwest error: {e}"),
            Self::UnDeserializeable(e) => write!(f, "Serde error: {e}"),
            ApiErr::Other(e) => write!(f, "Other error: {e}"),
        }
    }
}

impl Error for ApiErr {}

/// Result type for API
pub type ApiResult<T> = Result<T, ApiErr>;