-
Notifications
You must be signed in to change notification settings - Fork 66.7k
Expand file tree
/
Copy pathhandle-exceptions.ts
More file actions
27 lines (24 loc) · 971 Bytes
/
handle-exceptions.ts
File metadata and controls
27 lines (24 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import FailBot from './failbot'
import { toError } from '@/observability/lib/to-error'
import { createLogger } from '@/observability/logger'
const logger = createLogger(import.meta.url)
process.on('uncaughtException', async (err: Error | unknown) => {
const error = toError(err)
logger.error('uncaughtException', { error })
try {
FailBot.report(error)
} catch (failBotError) {
logger.warn('Even sending the uncaughtException error to FailBot failed!')
logger.error('Failed to report uncaughtException to FailBot', { error: toError(failBotError) })
}
})
process.on('unhandledRejection', async (err: Error | unknown) => {
const error = toError(err)
logger.error('unhandledRejection', { error })
try {
FailBot.report(error)
} catch (failBotError) {
logger.warn('Even sending the unhandledRejection error to FailBot failed!')
logger.error('Failed to report unhandledRejection to FailBot', { error: toError(failBotError) })
}
})