summaryrefslogtreecommitdiffstats
path: root/libimagentryview
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-05-15 16:53:31 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-05-17 00:26:36 +0200
commitea98cc41da8e6d8ac843265f70c2e4345c42920e (patch)
tree58a1a3ba64a5fc61118c984da76494abcde98433 /libimagentryview
parent5c7412ebc6cf48b9814085b83987d6d2086c8c13 (diff)
libimagentryview: Replace error code with code generator macro
Diffstat (limited to 'libimagentryview')
-rw-r--r--libimagentryview/Cargo.toml3
-rw-r--r--libimagentryview/src/error.rs77
-rw-r--r--libimagentryview/src/lib.rs1
3 files changed, 7 insertions, 74 deletions
diff --git a/libimagentryview/Cargo.toml b/libimagentryview/Cargo.toml
index e9711be0..7c0124a3 100644
--- a/libimagentryview/Cargo.toml
+++ b/libimagentryview/Cargo.toml
@@ -8,3 +8,6 @@ authors = ["Matthias Beyer <mail@beyermatthias.de>"]
[dependencies.libimagstore]
path = "../libimagstore"
+[dependencies.libimagerror]
+path = "../libimagerror"
+
diff --git a/libimagentryview/src/error.rs b/libimagentryview/src/error.rs
index 4bc8af54..32982342 100644
--- a/libimagentryview/src/error.rs
+++ b/libimagentryview/src/error.rs
@@ -2,78 +2,7 @@ use std::error::Error;
use std::fmt::Error as FmtError;
use std::fmt::{Display, Formatter};
-/**
- * Kind of error
- */
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum ViewErrorKind {
-}
-
-fn counter_error_type_as_str(e: &ViewErrorKind) -> &'static str {
- match e {
- _ => "",
- }
-}
-
-impl Display for ViewErrorKind {
-
- fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> {
- try!(write!(fmt, "{}", counter_error_type_as_str(self)));
- Ok(())
- }
-
-}
-
-/**
- * Store error type
- */
-#[derive(Debug)]
-pub struct ViewError {
- err_type: ViewErrorKind,
- cause: Option<Box<Error>>,
-}
-
-impl ViewError {
-
- /**
- * Build a new ViewError from an ViewErrorKind, optionally with cause
- */
- pub fn new(errtype: ViewErrorKind, cause: Option<Box<Error>>)
- -> ViewError
- {
- ViewError {
- err_type: errtype,
- cause: cause,
- }
- }
-
- /**
- * Get the error type of this ViewError
- */
- pub fn err_type(&self) -> ViewErrorKind {
- self.err_type
- }
-
-}
-
-impl Display for ViewError {
-
- fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> {
- try!(write!(fmt, "[{}]", counter_error_type_as_str(&self.err_type)));
- Ok(())
- }
-
-}
-
-impl Error for ViewError {
-
- fn description(&self) -> &str {
- counter_error_type_as_str(&self.err_type)
- }
-
- fn cause(&self) -> Option<&Error> {
- self.cause.as_ref().map(|e| &**e)
- }
-
-}
+generate_error_types!(ViewError, ViewErrorKind,
+ Unknown => "Unknown view error"
+);
diff --git a/libimagentryview/src/lib.rs b/libimagentryview/src/lib.rs
index 73833b7d..950332c5 100644
--- a/libimagentryview/src/lib.rs
+++ b/libimagentryview/src/lib.rs
@@ -15,6 +15,7 @@
)]
extern crate libimagstore;
+#[macro_use] extern crate libimagerror;
pub mod error;
pub mod builtin;