Skip to content

Commit

Permalink
Implement the std::error::Error trait for ProviderError
Browse files Browse the repository at this point in the history
  • Loading branch information
iddm committed Dec 17, 2023
1 parent bf6fe7a commit 60be2f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "urlshortener"
version = "3.0.2"
version = "3.1.0"
edition = "2018"
authors = ["Victor Polevoy <[email protected]>"]
description = "A very simple url shortener client library"
Expand Down
11 changes: 11 additions & 0 deletions src/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ pub enum ProviderError {
Deserialize,
}

impl std::fmt::Display for ProviderError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
Self::Connection => write!(f, "A connection problem occured when connecting to a provided."),
Self::Deserialize => write!(f, "Couldn't deserialize the shortened URL from the response."),
}
}
}

impl std::error::Error for ProviderError {}

/// A slice of all `Provider` variants which do not require authentication.
/// This list is in order of provider quality.
///
Expand Down

0 comments on commit 60be2f3

Please sign in to comment.