use http::StatusCode;
use reqwest;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ApiError {
#[error("Missing field in json response: {0}")]
MissingFieldError(&'static str),
#[error("Cannot convert field {0} to type {1}")]
InvalidTypeError(&'static str, &'static str),
#[error("Not authenticated")]
NotAuthenticatedError(StatusCode),
#[error("Network trouble: {0}")]
NetworkError(#[from] reqwest::Error),
#[error("IO trouble: {0}")]
IOError(#[from] std::io::Error),
}