MCPcopy Create free account
hub / github.com/agent-tower/core / installProcessErrorLogging

Function installProcessErrorLogging

packages/server/src/utils/error-log.ts:53–80  ·  view source on GitHub ↗
(dataDir?: string)

Source from the content-addressed store, hash-verified

51}
52
53export function installProcessErrorLogging(dataDir?: string): void {
54 if (processHandlersInstalled) return;
55 processHandlersInstalled = true;
56
57 process.on('uncaughtExceptionMonitor', (error) => {
58 if (loggedUnhandledRejections.has(error)) return;
59 writeErrorLog({
60 level: 'error',
61 source: 'process.uncaughtException',
62 message: error instanceof Error ? error.message : String(error),
63 error,
64 }, { dataDir });
65 });
66
67 process.on('unhandledRejection', (reason) => {
68 const error = reason instanceof Error ? reason : new Error(`Unhandled rejection: ${String(reason)}`);
69 writeErrorLog({
70 level: 'error',
71 source: 'process.unhandledRejection',
72 message: error.message,
73 error,
74 }, { dataDir });
75 loggedUnhandledRejections.add(error);
76 setImmediate(() => {
77 throw error;
78 });
79 });
80}
81
82export function formatErrorLogEntry(entry: ErrorLogEntry, now = new Date()): string {
83 const error = normalizeError(entry.error);

Callers 2

index.tsFile · 0.85
mainFunction · 0.85

Calls 3

writeErrorLogFunction · 0.85
onMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected