Skip to content

Commit

Permalink
Modify the error.rs
Browse files Browse the repository at this point in the history
To integrate with the cdown/geoip-http
  • Loading branch information
ip2location committed Oct 10, 2023
1 parent 5846b8e commit 095237b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ip2location"
version = "0.4.2"
version = "0.4.3"
authors = ["MARIRS <marirs@gmail.com>"]
description = "Find geo information & proxy information based on the given IP using IP2Location BIN databases"
keywords = ["ip2location", "geoip", "geolocation", "ip", "proxy"]
Expand Down
7 changes: 5 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fmt, io};

#[derive(PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq)]
pub enum Error {
GenericError(String),
IoError(String),
Expand All @@ -15,6 +15,9 @@ impl From<io::Error> for Error {
}
}

// Use default implementation for `std::error::Error`
impl std::error::Error for Error {}

impl From<&str> for Error {
fn from(err: &str) -> Error {
Error::GenericError(err.to_string())
Expand All @@ -39,7 +42,7 @@ impl From<std::net::AddrParseError> for Error {
}
}

impl fmt::Debug for Error {
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::GenericError(msg) => write!(f, "GenericError: {}", msg)?,
Expand Down

0 comments on commit 095237b

Please sign in to comment.