forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeGlobalHandlerPlugin.ts
More file actions
33 lines (25 loc) · 860 Bytes
/
NodeGlobalHandlerPlugin.ts
File metadata and controls
33 lines (25 loc) · 860 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
28
29
30
31
32
33
import {
ExceptionlessClient,
IEventPlugin,
PluginContext
} from "@exceptionless/core";
import { addListener } from "process";
export class NodeGlobalHandlerPlugin implements IEventPlugin {
public priority: number = 100;
public name: string = "NodeGlobalHandlerPlugin";
private _client: ExceptionlessClient = null;
public startup(context: PluginContext): Promise<void> {
if (this._client) {
return Promise.resolve();
}
this._client = context.client;
Error.stackTraceLimit = 50;
addListener("uncaughtException", async (error: Error) => {
await this._client.submitUnhandledException(error, "uncaughtException");
});
addListener("unhandledRejection", async (error: Error) => {
await this._client.submitUnhandledException(error, "unhandledRejection");
});
return Promise.resolve();
}
}