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

Function installFatalHandlers

src/bin/fatal-handler.ts:79–93  ·  view source on GitHub ↗
(deps: FatalHandlerDeps = {})

Source from the content-addressed store, hash-verified

77 * bounded line and then exit non-zero (Node's default fatal semantics).
78 */
79export function installFatalHandlers(deps: FatalHandlerDeps = {}): void {
80 const target = deps.target ?? process;
81 const exit = deps.exit ?? ((code: number) => process.exit(code));
82 const write = deps.write ?? writeStderr;
83
84 target.on('uncaughtException', (error: unknown) => {
85 write(`[CodeGraph] Uncaught exception: ${describeFatal(error)}\n`);
86 exit(1);
87 });
88
89 target.on('unhandledRejection', (reason: unknown) => {
90 write(`[CodeGraph] Unhandled rejection: ${describeFatal(reason)}\n`);
91 exit(1);
92 });
93}

Callers 2

codegraph.tsFile · 0.90
harnessFunction · 0.90

Calls 3

describeFatalFunction · 0.85
onMethod · 0.65
writeFunction · 0.50

Tested by 1

harnessFunction · 0.72