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

Function toReportableError

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

Source from the content-addressed store, hash-verified

107};
108
109export const toReportableError = (error: unknown, context: FrontendErrorContext): Error => {
110 if (Cause.isCause(error)) return errorFromCause(error, context);
111 // 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
112 if (error instanceof Error) {
113 // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: narrowed to Error above; an empty message is exactly the case being repaired
114 if (hasText(error.message)) return error;
115 // Never mutate an Error a call site owns: rebuild it, carrying the stack.
116 // oxlint-disable-next-line executor/no-error-constructor -- boundary: a crash-reporting transport only understands built-in Errors
117 const titled = new Error(describeUnknown(error, context));
118 titled.name = error.name;
119 if (typeof error.stack === "string") titled.stack = error.stack;
120 return withOriginalCause(titled, error);
121 }
122 return errorFromValue(error, context);
123};
124
125/** Wraps a reporter so it can only ever be handed a titled `Error`. */
126const 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