MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / toReportableError

Function toReportableError

packages/react/src/api/error-reporting.tsx:100–114  ·  view source on GitHub ↗
(error: unknown, context: FrontendErrorContext)

Source from the content-addressed store, hash-verified

98};
99
100export const toReportableError = (error: unknown, context: FrontendErrorContext): Error => {
101 if (Cause.isCause(error)) return errorFromCause(error, context);
102 // oxlint-disable-next-line executor/no-instanceof-error -- boundary: the report is already whatever a call site threw; deciding whether the transport can consume it as-is is this adapter's whole job
103 if (error instanceof Error) {
104 // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: narrowed to Error above; an empty message is exactly the case being repaired
105 if (hasText(error.message)) return error;
106 // Never mutate an Error a call site owns: rebuild it, carrying the stack.
107 // oxlint-disable-next-line executor/no-error-constructor -- boundary: a crash-reporting transport only understands built-in Errors
108 const titled = new Error(describeUnknown(error, context));
109 titled.name = error.name;
110 if (typeof error.stack === "string") titled.stack = error.stack;
111 return withOriginalCause(titled, error);
112 }
113 return errorFromValue(error, context);
114};
115
116/** Wraps a reporter so it can only ever be handed a titled `Error`. */
117const normalizing =

Callers 6

normalizingFunction · 0.85
reportExitFailureFunction · 0.85
reportCauseFailureFunction · 0.85

Calls 5

errorFromCauseFunction · 0.85
hasTextFunction · 0.85
describeUnknownFunction · 0.85
withOriginalCauseFunction · 0.85
errorFromValueFunction · 0.85

Tested by

no test coverage detected