-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.d.ts
59 lines (55 loc) · 1.19 KB
/
main.d.ts
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Process event name
*/
export type Event =
| 'uncaughtException'
| 'warning'
| 'unhandledRejection'
| 'rejectionHandled'
export interface Options {
/**
* Prevent exiting the process on
* [uncaught exceptions](https://nodejs.org/api/process.html#process_event_uncaughtexception)
* or
* [unhandled promises](https://nodejs.org/api/process.html#process_event_unhandledrejection).
*
* @default false
*/
readonly exit?: boolean
/**
* Function called once per process error.
* Duplicate process errors are ignored.
*
* @default console.error(error)
*
* @example
* ```js
* // Log process errors with Winston instead
* logProcessErrors({
* onError(error, event) {
* winstonLogger.error(error.stack)
* },
* })
* ```
*/
readonly onError?: (error: Error, event: Event) => Promise<void> | void
}
/**
* Restores Node.js default behavior.
*
* @example
* ```js
* const restore = logProcessErrors(options)
* restore()
* ```
*/
type Undo = () => void
/**
* Improve how process errors are logged.
*
* @example
* ```js
* logProcessErrors(options)
* ```
*/
export default function logProcessErrors(options?: Options): Undo