forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventContext.ts
More file actions
42 lines (33 loc) · 1.01 KB
/
EventContext.ts
File metadata and controls
42 lines (33 loc) · 1.01 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
37
38
39
40
41
42
const enum KnownContextKeys {
Exception = "@@_Exception",
IsUnhandledError = "@@_IsUnhandledError",
SubmissionMethod = "@@_SubmissionMethod"
}
export class EventContext implements Record<string, unknown> {
[x: string]: unknown;
public getException(): Error | null {
return this[KnownContextKeys.Exception] as Error || null;
}
public setException(exception: Error): void {
if (exception) {
this[KnownContextKeys.Exception] = exception;
}
}
public get hasException(): boolean {
return !!this[KnownContextKeys.Exception];
}
public markAsUnhandledError(): void {
this[KnownContextKeys.IsUnhandledError] = true;
}
public get isUnhandledError(): boolean {
return !!this[KnownContextKeys.IsUnhandledError];
}
public getSubmissionMethod(): string | null {
return this[KnownContextKeys.SubmissionMethod] as string || null;
}
public setSubmissionMethod(method: string): void {
if (method) {
this[KnownContextKeys.SubmissionMethod] = method;
}
}
}