From 536534bb042503861e63bdb701b948090bc11dfb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 5 Aug 2023 18:06:29 +0100 Subject: [PATCH] Add source to Error --- src/errors.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/errors.rs b/src/errors.rs index d8f4236..1135c29 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -3,11 +3,13 @@ use std::{str::Utf8Error, string::FromUtf8Error}; #[derive(Debug)] pub struct Error { pub details: String, + pub source: String, } impl Error { pub fn message(details: &str) -> Self { Self { details: details.to_string(), + source: "(not provided)".to_string(), } } } @@ -15,6 +17,7 @@ impl From for Error { fn from(value: Utf8Error) -> Self { Self { details: value.to_string(), + source: "Utf8Error".to_string(), } } } @@ -22,18 +25,23 @@ impl From for Error { fn from(value: FromUtf8Error) -> Self { Self { details: value.to_string(), + source: "FromUtf8Error".to_string(), } } } impl From for Error { fn from(details: String) -> Self { - Self { details } + Self { + details, + source: "String".to_string(), + } } } impl From for Error { fn from(value: std::io::Error) -> Self { Self { details: value.to_string(), + source: "std::io::Error".to_string(), } } } @@ -41,6 +49,7 @@ impl From> for Error { fn from(value: std::sync::mpsc::SendError) -> Self { Self { details: value.to_string(), + source: "std::sync::mpsc::SendError".to_string(), } } } @@ -48,6 +57,7 @@ impl From for Error { fn from(value: atom_syndication::Error) -> Self { Self { details: value.to_string(), + source: "atom_syndication::Error".to_string(), } } } @@ -55,6 +65,7 @@ impl From for Error { fn from(value: reqwest::Error) -> Self { Self { details: value.to_string(), + source: "reqwest::Error".to_string(), } } }