aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2020-10-09 13:34:59 -0700
committerRichard Walters <rwalters@digitalstirling.com>2020-10-09 13:34:59 -0700
commitc1605ada3340fe1a5b32bd93fc08e0c649dc8a52 (patch)
tree9a7dbe8cc0cefebdd92550e0fc589157131d77b6
parent5d744a843c0fb8af675240a20f13cd48100d32f9 (diff)
Implement std::error::Error for custom error types
-rw-r--r--src/lib.rs6
-rw-r--r--src/percent_encoded_character_decoder.rs6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 3b3a02c..375deb3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -178,6 +178,12 @@ impl std::fmt::Display for Error {
}
}
+impl std::error::Error for Error {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ None
+ }
+}
+
impl From<percent_encoded_character_decoder::Error> for Error {
fn from(error: percent_encoded_character_decoder::Error) -> Self {
match error {
diff --git a/src/percent_encoded_character_decoder.rs b/src/percent_encoded_character_decoder.rs
index 2fd2753..781a643 100644
--- a/src/percent_encoded_character_decoder.rs
+++ b/src/percent_encoded_character_decoder.rs
@@ -44,6 +44,12 @@ impl std::fmt::Display for Error {
}
}
+impl std::error::Error for Error {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ None
+ }
+}
+
pub struct PercentEncodedCharacterDecoder {
decoded_character: u8,
digits_left: usize,