MCPcopy Create free account
hub / github.com/hashintel/hash / bail

Function bail

libs/error-stack/tests/test_macros.rs:9–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8#[test]
9fn bail() {
10 let report = capture_error(|| bail!(RootError)).attach(PrintableA(0));
11 assert!(report.contains::<RootError>());
12 assert!(report.contains::<PrintableA>());
13 assert!(!report.contains::<PrintableB>());
14 assert_eq!(report.current_context(), &RootError);
15 assert_eq!(report.frames().count(), expect_count(2));
16 assert_eq!(
17 remove_builtin_messages(messages(&report)),
18 remove_builtin_messages(["printable A", "root error"])
19 );
20
21 let report = capture_error(|| bail!(report)).attach(PrintableB(0));
22 assert!(report.contains::<RootError>());
23 assert!(report.contains::<PrintableA>());
24 assert!(report.contains::<PrintableB>());
25 assert_eq!(report.current_context(), &RootError);
26 assert_eq!(report.frames().count(), expect_count(3));
27 assert_eq!(
28 remove_builtin_messages(messages(&report)),
29 remove_builtin_messages(["printable B", "printable A", "root error"])
30 );
31}
32
33#[test]
34fn ensure() {

Callers

nothing calls this directly

Calls 4

capture_errorFunction · 0.85
PrintableAClass · 0.85
PrintableBClass · 0.85
attachMethod · 0.45

Tested by

no test coverage detected