melib: add summary field to MeliError

jmap
Manos Pitsidianakis 2019-12-03 13:27:00 +02:00
parent 7010ee7495
commit a059e4ad4c
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 11 additions and 1 deletions

View File

@ -37,7 +37,8 @@ pub type Result<T> = result::Result<T, MeliError>;
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Deserialize, Serialize)]
pub struct MeliError { pub struct MeliError {
details: String, pub summary: Option<String>,
pub details: String,
} }
impl MeliError { impl MeliError {
@ -46,9 +47,18 @@ impl MeliError {
M: Into<String>, M: Into<String>,
{ {
MeliError { MeliError {
summary: None,
details: msg.into(), details: msg.into(),
} }
} }
pub fn set_summary<M>(mut self, summary: M) -> MeliError
where
M: Into<String>,
{
self.summary = Some(summary.into());
self
}
} }
impl fmt::Display for MeliError { impl fmt::Display for MeliError {