diff options
author | Bert Belder <bertbelder@gmail.com> | 2019-07-11 00:53:48 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-07-11 14:37:00 -0400 |
commit | abe8a113ad8004f160eac5f3f115cb28c5072ba7 (patch) | |
tree | 099b2b019bd7b5d1689cfa5b4bef3ceded10c59d /cli/diagnostics.rs | |
parent | db5c66a638d399d5ebb2832bb7b52e8f76ced49d (diff) |
Refactor error to use dynamic dispatch and traits
This is in preperation for dynamic import (#1789), which is more easily
implemented when errors are dynamic.
Diffstat (limited to 'cli/diagnostics.rs')
-rw-r--r-- | cli/diagnostics.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index 69b58459e..14f5ba2c4 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -7,6 +7,7 @@ use crate::fmt_errors::format_maybe_source_name; use crate::fmt_errors::DisplayFormatter; use serde_json; use serde_json::value::Value; +use std::error::Error; use std::fmt; #[derive(Debug, PartialEq, Clone)] @@ -66,6 +67,12 @@ impl fmt::Display for Diagnostic { } } +impl Error for Diagnostic { + fn description(&self) -> &str { + &self.items[0].message + } +} + #[derive(Debug, PartialEq, Clone)] pub struct DiagnosticItem { /// The top level message relating to the diagnostic item. |