summaryrefslogtreecommitdiffstats
path: root/lib/core
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-10-19 08:41:17 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-10-26 16:35:31 +0200
commit19f6391d8a6033c7a415d87cb5aa13daef67196a (patch)
tree740b257badf4bbad9a18423c863735b8ac616e07 /lib/core
parente3db947e685ab2d17bd41e17adc8ff90505cbcfb (diff)
Implement Error for ExitCode
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'lib/core')
-rw-r--r--lib/core/libimagerror/src/exit.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/core/libimagerror/src/exit.rs b/lib/core/libimagerror/src/exit.rs
index 40ac9b9f..85ae5466 100644
--- a/lib/core/libimagerror/src/exit.rs
+++ b/lib/core/libimagerror/src/exit.rs
@@ -17,6 +17,10 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
+use std::error::Error;
+use std::fmt::{Formatter, Display};
+
+#[derive(Debug)]
pub struct ExitCode(i32);
impl From<i32> for ExitCode {
@@ -31,6 +35,26 @@ impl ExitCode {
}
}
+impl Display for ExitCode {
+ fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
+ write!(f, "ExitCode {}", self.0)
+ }
+}
+
+impl Error for ExitCode {
+ fn description(&self) -> &str {
+ "ExitCode"
+ }
+
+ fn cause(&self) -> Option<&dyn Error> {
+ None
+ }
+
+ fn source(&self) -> Option<&(dyn Error + 'static)> {
+ None
+ }
+}
+
pub trait ExitUnwrap<T> {
fn unwrap_or_exit(self) -> T;
}