diff options
author | rabite <rabite@posteo.de> | 2019-03-09 11:06:13 +0100 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-03-09 11:06:13 +0100 |
commit | 5d456539015876c1891bf0ac05b8f7dd3fbe8d57 (patch) | |
tree | 39e2e42cd28773eb9ac785d0430b51f72e6876d6 /src/fail.rs | |
parent | 6e02ef6486b6660b69136e19c7086e8b2b3eb7ee (diff) |
use enum to allow multiple widget types in hbox
Diffstat (limited to 'src/fail.rs')
-rw-r--r-- | src/fail.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/fail.rs b/src/fail.rs index a6f8abe..2c01885 100644 --- a/src/fail.rs +++ b/src/fail.rs @@ -45,13 +45,27 @@ pub enum HError { #[fail(display = "No header for widget")] NoHeaderError, #[fail(display = "You wanted this!")] - Quit + Quit, + #[fail(display = "HBox ratio mismatch: {} widgets, ratio is {:?}", wnum, ratio)] + HBoxWrongRatioError{ wnum: usize, ratio: Vec<usize> }, + #[fail(display = "Got wrong widget: {}! Wanted: {}", got, wanted)] + WrongWidgetError{got: String, wanted: String}, } impl HError { pub fn quit() -> HResult<()> { Err(HError::Quit) } + pub fn wrong_ratio<T>(wnum: usize, ratio: Vec<usize>) -> HResult<T> { + Err(HError::HBoxWrongRatioError{ wnum: wnum, ratio: ratio }) + } + pub fn no_widget<T>() -> HResult<T> { + Err(HError::NoWidgetError(Backtrace::new())) + } + pub fn wrong_widget<T>(got: &str, wanted: &str) -> HResult<T> { + Err(HError::WrongWidgetError{ got: got.to_string(), + wanted: wanted.to_string()}) + } } pub trait ErrorLog where Self: Sized { |