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

Function anyhow_output

libs/error-stack/tests/test_compatibility.rs:103–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101#[test]
102#[cfg(feature = "anyhow")]
103fn anyhow_output() {
104 let anyhow = anyhow::anyhow!(RootError)
105 .context(PrintableA(0))
106 .context(PrintableB(0));
107
108 let anyhow_debug_normal = format!("{anyhow:?}");
109 let anyhow_debug_extended = format!("{anyhow:#?}");
110 let anyhow_display_normal = format!("{anyhow:}");
111 let anyhow_display_extended = format!("{anyhow:#}");
112
113 let anyhow_report = Err::<(), _>(anyhow)
114 .into_report()
115 .expect_err("should have returned error");
116 let context = anyhow_report.current_context();
117
118 let context_debug_normal = format!("{context:?}");
119 let context_debug_extended = format!("{context:#?}");
120 let context_display_normal = format!("{context:}");
121 let context_display_extended = format!("{context:#}");
122
123 assert_eq!(anyhow_debug_normal, context_debug_normal);
124 assert_eq!(anyhow_debug_extended, context_debug_extended);
125 assert_eq!(anyhow_display_normal, context_display_normal);
126 assert_eq!(anyhow_display_extended, context_display_extended);
127}
128
129#[cfg(feature = "eyre")]
130fn install_eyre_hook() {

Callers

nothing calls this directly

Calls 5

PrintableAClass · 0.85
PrintableBClass · 0.85
current_contextMethod · 0.80
contextMethod · 0.45
into_reportMethod · 0.45

Tested by

no test coverage detected