ip_api4rs/
error.rs

1//! A module that contains the error type for the library.
2
3use crate::model::ip_response::ErrorResponse;
4use thiserror::Error;
5
6/// An enum that contains all the possible errors that can occur when querying the API.
7#[derive(Error, Debug)]
8pub enum IpApiError {
9    #[error("The supplied ip address is in a reserved range.")]
10    ReservedRange(ErrorResponse),
11    #[error("The supplied ip address is invalid.")]
12    InvalidQuery(ErrorResponse),
13    #[error("An error occurred while parsing the JSON.")]
14    JsonParseError(#[from] serde_json::Error),
15    #[error("An error occurred while querying the API.")]
16    ReqwestError(#[from] reqwest::Error),
17    #[error("An unknown error occurred.")]
18    Unknown(String),
19}