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

Method install_debug_hook

libs/error-stack/src/hook/mod.rs:197–216  ·  view source on GitHub ↗
(
        hook: impl Fn(&T, &mut crate::fmt::HookContext<T>) + Send + Sync + 'static,
    )

Source from the content-addressed store, hash-verified

195 /// [`Error::provide`]: std::error::Error::provide
196 #[cfg(any(feature = "std", feature = "hooks"))]
197 pub fn install_debug_hook<T: Send + Sync + 'static>(
198 hook: impl Fn(&T, &mut crate::fmt::HookContext<T>) + Send + Sync + 'static,
199 ) {
200 install_builtin_hooks();
201
202 // TODO: Use `let ... else` when MSRV is 1.65
203 #[cfg(feature = "std")]
204 let mut lock = FMT_HOOK.write().unwrap_or_else(|_| {
205 unreachable!(
206 "Hook is poisoned. This is considered a bug and should be reported to \
207 https://github.com/hashintel/hash/issues/new/choose"
208 )
209 });
210
211 // The spin RwLock cannot panic
212 #[cfg(all(not(feature = "std"), feature = "hooks"))]
213 let mut lock = FMT_HOOK.write();
214
215 lock.insert(hook);
216 }
217
218 /// Returns the hook that was previously set by [`install_debug_hook`].
219 ///

Callers

nothing calls this directly

Calls 3

install_builtin_hooksFunction · 0.85
writeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected