#[non_exhaustive]pub enum Error {
Api {
message: String,
http_status: Option<u16>,
retry_after: Option<u64>,
},
Network {
message: String,
},
InvalidArgument {
message: String,
},
}Expand description
All errors returned by this crate.
Every variant carries a human-readable message. API errors additionally
carry the upstream HTTP status code, and HTTP 429 responses on the free
plan also carry the Retry-After value the API asked us to honour
(the paid endpoint does not send the header).
Match on the variant when you want to branch on the category, or call
Error::error_type to get a stable category string
("api", "network", "invalid_argument").
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api
The ipwhois.io API itself returned an error. Covers HTTP 4xx / 5xx
responses, malformed JSON bodies, and HTTP 2xx responses where the
API sets success: false (e.g. “Invalid IP address”,
“Reserved range”).
Fields
message: StringHuman-readable description from the API or synthesised by the client when the body is unparseable.
Network
Transport-level failure: DNS, connection refused, TLS handshake, timeout, etc. The request never reached the API meaningfully.
InvalidArgument
The caller supplied an invalid argument before any request was made (unsupported language, empty bulk list, more than 100 IPs, …).
Implementations§
Source§impl Error
impl Error
Sourcepub fn error_type(&self) -> &'static str
pub fn error_type(&self) -> &'static str
Stable string identifying the category of this error.
Returns one of: "api", "network", or "invalid_argument".
Sourcepub fn http_status(&self) -> Option<u16>
pub fn http_status(&self) -> Option<u16>
HTTP status code, if this is an Error::Api variant carrying one.
Sourcepub fn retry_after(&self) -> Option<u64>
pub fn retry_after(&self) -> Option<u64>
Value of the Retry-After header in seconds, if available.
Only present on HTTP 429 responses from the free plan.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()