1use std::net::AddrParseError;
4use std::num::ParseIntError;
5use thiserror::Error;
6
7#[derive(Clone, Debug, Error)]
9#[non_exhaustive]
10pub enum Error {
11 #[error("Invalid GeoIP data file: {0}")]
13 BadFormat(&'static str),
14 #[error("Unsupported country code in file: {0}")]
16 BadCountryCode(String),
17
18 #[error("The 'nowhere' country code ('??') is not supported in this context.")]
20 NowhereNotSupported,
21}
22
23impl From<ParseIntError> for Error {
24 fn from(_e: ParseIntError) -> Error {
25 Error::BadFormat("can't parse number")
26 }
27}
28
29impl From<AddrParseError> for Error {
30 fn from(_e: AddrParseError) -> Error {
31 Error::BadFormat("can't parse IPv6 address")
32 }
33}