MCPcopy
hub / github.com/colbymchenry/codegraph / describeFatal

Function describeFatal

src/bin/fatal-handler.ts:40–54  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

38 * formatting. Pure and total — never throws, never touches `.stack`.
39 */
40export function describeFatal(value: unknown): string {
41 if (value instanceof Error) {
42 const name = typeof value.name === 'string' && value.name ? value.name : 'Error';
43 // `message` is a plain own/proto string property — reading it does NOT
44 // format the stack (which is what can loop forever, #850).
45 const message = typeof value.message === 'string' ? value.message : '';
46 return message ? `${name}: ${message}` : name;
47 }
48 try {
49 return String(value);
50 } catch {
51 // e.g. an object with a throwing `toString` / `Symbol.toPrimitive`.
52 return '<unstringifiable value>';
53 }
54}
55
56/** Best-effort synchronous stderr write that can never keep a doomed process alive. */
57function writeStderr(line: string): void {

Callers 2

installFatalHandlersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected