Skip to content

Commit e86de9b

Browse files
committed
Add test for chain_error used with internal
1 parent a5a451e commit e86de9b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/util/errors.rs

+20
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,23 @@ impl fmt::Display for TooManyRequests {
342342
"Too many requests".fmt(f)
343343
}
344344
}
345+
346+
#[test]
347+
fn chain_error_internal() {
348+
assert_eq!(
349+
None::<()>
350+
.chain_error(|| internal("inner"))
351+
.chain_error(|| internal("middle"))
352+
.chain_error(|| internal("outer"))
353+
.unwrap_err()
354+
.to_string(),
355+
"outer caused by middle caused by inner"
356+
);
357+
assert_eq!(
358+
Err::<(), _>(internal("inner"))
359+
.chain_error(|| internal("outer"))
360+
.unwrap_err()
361+
.to_string(),
362+
"outer caused by inner"
363+
);
364+
}

0 commit comments

Comments
 (0)