@grest-ts/common 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +81 -81
- package/dist/src/GGExtensionDiscovery.d.ts.map +1 -1
- package/dist/src/GGExtensionDiscovery.js +3 -1
- package/dist/src/GGExtensionDiscovery.js.map +1 -1
- package/dist/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/GGAsyncStorage.ts +27 -27
- package/src/GGError.ts +74 -74
- package/src/GGExtensionDiscovery.ts +316 -314
- package/src/Secret.ts +76 -76
- package/src/UnreachableCode.ts +9 -9
- package/src/deepClone.ts +43 -43
- package/src/deepFreeze.ts +21 -21
- package/src/environment.ts +22 -22
- package/src/http.ts +51 -51
- package/src/index-browser.ts +12 -12
- package/src/index-node.ts +11 -11
- package/src/sleep.ts +2 -2
- package/src/types.ts +15 -15
- package/src/withTimeout.ts +20 -20
package/src/GGError.ts
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context for constructing GGError instances
|
|
3
|
-
* This is ONLY an input parameter - not stored on the error object
|
|
4
|
-
* All fields become direct readonly properties on GGError
|
|
5
|
-
*/
|
|
6
|
-
export interface GGErrorContext {
|
|
7
|
-
displayMessage?: string;
|
|
8
|
-
debugMessage?: string;
|
|
9
|
-
debugData?: any
|
|
10
|
-
originalError?: GGError | Error | string | unknown;
|
|
11
|
-
|
|
12
|
-
// Internal: Used only for deserialization from JSON
|
|
13
|
-
refId?: string;
|
|
14
|
-
timestamp?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* These values are only returned when running tests or locally.
|
|
19
|
-
*/
|
|
20
|
-
export interface GGErrorDebugMessage {
|
|
21
|
-
debugMessage?: string;
|
|
22
|
-
debugData?: any
|
|
23
|
-
originalError?: GGErrorDebugMessage | Error | string | unknown;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class GGError extends Error {
|
|
27
|
-
|
|
28
|
-
public readonly refId: string;
|
|
29
|
-
public readonly timestamp: number;
|
|
30
|
-
public readonly displayMessage?: string;
|
|
31
|
-
public readonly debugMessage?: string;
|
|
32
|
-
public readonly debugData?: any;
|
|
33
|
-
public readonly originalError?: GGError | Error | string | unknown;
|
|
34
|
-
|
|
35
|
-
constructor(message: string, context?: GGErrorContext | Error) {
|
|
36
|
-
|
|
37
|
-
if (context instanceof Error) {
|
|
38
|
-
context = {
|
|
39
|
-
originalError: context
|
|
40
|
-
}
|
|
41
|
-
} else if (!context) {
|
|
42
|
-
context = {};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let refId: string;
|
|
46
|
-
let timestamp: number;
|
|
47
|
-
if (context.originalError instanceof GGError) {
|
|
48
|
-
refId = context.originalError.refId;
|
|
49
|
-
timestamp = context.originalError.timestamp;
|
|
50
|
-
} else {
|
|
51
|
-
refId = context.refId ?? "ERR_REF_" + Math.random().toString(36).substring(2, 10) + Date.now().toString(36);
|
|
52
|
-
timestamp = context.timestamp ?? Date.now();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
super(message + " {" + refId + "} " + (context?.displayMessage ? ": " + context?.displayMessage : ""));
|
|
56
|
-
this.refId = refId
|
|
57
|
-
this.timestamp = timestamp
|
|
58
|
-
this.displayMessage = context.displayMessage;
|
|
59
|
-
this.debugMessage = context.debugMessage;
|
|
60
|
-
this.debugData = context.debugData;
|
|
61
|
-
this.originalError = context.originalError;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public static fromUnknown(error: unknown): GGError {
|
|
65
|
-
if (error instanceof GGError) {
|
|
66
|
-
return error;
|
|
67
|
-
} else if (error instanceof Error) {
|
|
68
|
-
return new GGError(error.message, error);
|
|
69
|
-
} else {
|
|
70
|
-
return new GGError("Unknown", {debugData: error});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Context for constructing GGError instances
|
|
3
|
+
* This is ONLY an input parameter - not stored on the error object
|
|
4
|
+
* All fields become direct readonly properties on GGError
|
|
5
|
+
*/
|
|
6
|
+
export interface GGErrorContext {
|
|
7
|
+
displayMessage?: string;
|
|
8
|
+
debugMessage?: string;
|
|
9
|
+
debugData?: any
|
|
10
|
+
originalError?: GGError | Error | string | unknown;
|
|
11
|
+
|
|
12
|
+
// Internal: Used only for deserialization from JSON
|
|
13
|
+
refId?: string;
|
|
14
|
+
timestamp?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* These values are only returned when running tests or locally.
|
|
19
|
+
*/
|
|
20
|
+
export interface GGErrorDebugMessage {
|
|
21
|
+
debugMessage?: string;
|
|
22
|
+
debugData?: any
|
|
23
|
+
originalError?: GGErrorDebugMessage | Error | string | unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class GGError extends Error {
|
|
27
|
+
|
|
28
|
+
public readonly refId: string;
|
|
29
|
+
public readonly timestamp: number;
|
|
30
|
+
public readonly displayMessage?: string;
|
|
31
|
+
public readonly debugMessage?: string;
|
|
32
|
+
public readonly debugData?: any;
|
|
33
|
+
public readonly originalError?: GGError | Error | string | unknown;
|
|
34
|
+
|
|
35
|
+
constructor(message: string, context?: GGErrorContext | Error) {
|
|
36
|
+
|
|
37
|
+
if (context instanceof Error) {
|
|
38
|
+
context = {
|
|
39
|
+
originalError: context
|
|
40
|
+
}
|
|
41
|
+
} else if (!context) {
|
|
42
|
+
context = {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let refId: string;
|
|
46
|
+
let timestamp: number;
|
|
47
|
+
if (context.originalError instanceof GGError) {
|
|
48
|
+
refId = context.originalError.refId;
|
|
49
|
+
timestamp = context.originalError.timestamp;
|
|
50
|
+
} else {
|
|
51
|
+
refId = context.refId ?? "ERR_REF_" + Math.random().toString(36).substring(2, 10) + Date.now().toString(36);
|
|
52
|
+
timestamp = context.timestamp ?? Date.now();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
super(message + " {" + refId + "} " + (context?.displayMessage ? ": " + context?.displayMessage : ""));
|
|
56
|
+
this.refId = refId
|
|
57
|
+
this.timestamp = timestamp
|
|
58
|
+
this.displayMessage = context.displayMessage;
|
|
59
|
+
this.debugMessage = context.debugMessage;
|
|
60
|
+
this.debugData = context.debugData;
|
|
61
|
+
this.originalError = context.originalError;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public static fromUnknown(error: unknown): GGError {
|
|
65
|
+
if (error instanceof GGError) {
|
|
66
|
+
return error;
|
|
67
|
+
} else if (error instanceof Error) {
|
|
68
|
+
return new GGError(error.message, error);
|
|
69
|
+
} else {
|
|
70
|
+
return new GGError("Unknown", {debugData: error});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|