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

Function debug_attachments_invoke

libs/error-stack/src/fmt/mod.rs:835–892  ·  view source on GitHub ↗
(
    frames: impl IntoIterator<Item = &'a Frame>,
    config: &mut Config,
)

Source from the content-addressed store, hash-verified

833 expect(clippy::needless_pass_by_ref_mut)
834)]
835fn debug_attachments_invoke<'a>(
836 frames: impl IntoIterator<Item = &'a Frame>,
837 config: &mut Config,
838) -> (Opaque, Vec<String>) {
839 let mut opaque = Opaque::new();
840
841 #[cfg(any(feature = "std", feature = "hooks"))]
842 let context = config.context();
843
844 let body = frames
845 .into_iter()
846 .map(|frame| match frame.kind() {
847 #[cfg(any(feature = "std", feature = "hooks"))]
848 FrameKind::Context(_) => Some(
849 if Report::invoke_debug_format_hook(|hooks| hooks.call(frame, context)) {
850 context.take_body()
851 } else {
852 Vec::new()
853 },
854 ),
855 #[cfg(any(feature = "std", feature = "hooks"))]
856 FrameKind::Attachment(AttachmentKind::Printable(attachment)) => Some(
857 if Report::invoke_debug_format_hook(|hooks| hooks.call(frame, context)) {
858 context.take_body()
859 } else {
860 vec![attachment.to_string()]
861 },
862 ),
863 #[cfg(any(feature = "std", feature = "hooks"))]
864 FrameKind::Attachment(AttachmentKind::Opaque(_)) => {
865 Report::invoke_debug_format_hook(|hooks| hooks.call(frame, context))
866 .then(|| context.take_body())
867 }
868 #[cfg(not(any(feature = "std", feature = "hooks")))]
869 FrameKind::Context(_) => Some(vec![]),
870 #[cfg(not(any(feature = "std", feature = "hooks")))]
871 FrameKind::Attachment(AttachmentKind::Printable(attachment)) => {
872 Some(vec![attachment.to_string()])
873 }
874 #[cfg(not(any(feature = "std", feature = "hooks")))]
875 FrameKind::Attachment(AttachmentKind::Opaque(_)) => frame
876 .downcast_ref::<core::panic::Location<'static>>()
877 .map(|location| {
878 vec![LocationAttachment::new(location, config.color_mode()).to_string()]
879 }),
880 })
881 .flat_map(|body| {
882 body.unwrap_or_else(|| {
883 // increase the opaque counter, if we're unable to determine the actual value of
884 // the frame
885 opaque.increase();
886 Vec::new()
887 })
888 })
889 .collect();
890
891 (opaque, body)
892}

Callers 1

debug_attachmentsFunction · 0.85

Calls 9

collectMethod · 0.80
take_bodyMethod · 0.80
thenMethod · 0.80
increaseMethod · 0.80
contextMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
kindMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected