errorx-macros 0.0.1

macros for the errorx crate.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use errorx::ToError;
use errorx_macros::*;

#[derive(Error, Debug)]
pub enum CustomError {
    #[error(name = "hello", message = "world")]
    UnAuthorized,
}

#[test]
pub fn should_create_error() {
    let err = CustomError::UnAuthorized.to_error();
    debug_assert_eq!(err.to_string(), "hello: world");
    debug_assert_eq!(err.message(), Some("world"));
    debug_assert_eq!(err.name(), Some("hello"));
}