forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContextData.ts
More file actions
41 lines (33 loc) · 979 Bytes
/
ContextData.ts
File metadata and controls
41 lines (33 loc) · 979 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
34
35
36
37
38
39
40
41
const enum KnownContextKeys {
Exception = "@@_Exception",
IsUnhandledError = "@@_IsUnhandledError",
SubmissionMethod = "@@_SubmissionMethod"
}
// TODO: Look into ways of improving this.
export class ContextData {
public getException(): Error {
return this[KnownContextKeys.Exception] || 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 {
return this[KnownContextKeys.SubmissionMethod] || null;
}
public setSubmissionMethod(method: string): void {
if (method) {
this[KnownContextKeys.SubmissionMethod] = method;
}
}
}