forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobalHandlerPlugin.ts
More file actions
36 lines (29 loc) · 1.16 KB
/
GlobalHandlerPlugin.ts
File metadata and controls
36 lines (29 loc) · 1.16 KB
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
import {
ExceptionlessClient,
IEventPlugin,
PluginContext
} from "@exceptionless/core";
export class GlobalHandlerPlugin implements IEventPlugin {
public priority: number = 100;
public name: string = "GlobalHandlerPlugin";
private client: ExceptionlessClient = null;
public startup(context: PluginContext): Promise<void> {
if (this.client) {
return;
}
this.client = context.client;
Error.stackTraceLimit = Infinity;
// TODO: Discus if we want to unwire this handler in suspend?
const originalOnError: OnErrorEventHandlerNonNull = globalThis.onerror;
globalThis.onerror = (event: Event | string, source?: string, lineno?: number, colno?: number, error?: Error): any => {
/*
const builder = this.client.createUnhandledException(new Error(stackTrace.message || (options || {}).status || "Script error"), "onerror");
builder.pluginContextData["@@_TraceKit.StackTrace"] = stackTrace;
void builder.submit(); // TODO: Handle async?
*/
// eslint-disable-next-line prefer-rest-params
return originalOnError ? originalOnError.apply(this, ...arguments) : false;
};
return Promise.resolve();
}
}