blob: 574886db7e71864e25c6576caa4c9fa6d168e489 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#[macro_use]
extern crate failure;
use failure::Fail;
#[test]
fn test_name() {
#[derive(Fail, Debug)]
#[fail(display = "my error")]
struct MyError;
let err = MyError;
assert_eq!(err.to_string(), "my error");
assert_eq!(err.name(), Some("basic_fail::MyError"));
let ctx = err.context("whatever");
assert_eq!(ctx.to_string(), "whatever");
assert_eq!(ctx.name(), Some("basic_fail::MyError"));
}
|