@datapos/datapos-shared 0.3.564 → 0.3.566
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.
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
class
|
|
1
|
+
class c extends Error {
|
|
2
2
|
locator;
|
|
3
3
|
// Logical source of the error
|
|
4
4
|
constructor(o, s, r) {
|
|
5
5
|
super(o, r), this.name = "DPUError", this.locator = s;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
class
|
|
8
|
+
class E extends c {
|
|
9
9
|
body;
|
|
10
10
|
// Sanitized snapshot of the response body
|
|
11
11
|
constructor(o, s, r, t) {
|
|
12
|
-
super(o, s, t), this.name = "APIError", this.body =
|
|
12
|
+
super(o, s, t), this.name = "APIError", this.body = l(r ?? void 0);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
class
|
|
15
|
+
class d extends c {
|
|
16
16
|
constructor(o, s, r) {
|
|
17
17
|
super(o, s, r), this.name = "EngineError";
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
class
|
|
20
|
+
class m extends c {
|
|
21
21
|
constructor(o, s, r) {
|
|
22
22
|
super(o, s, r), this.name = "ConnectorError";
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
class i extends
|
|
25
|
+
class i extends c {
|
|
26
26
|
body;
|
|
27
27
|
// Sanitized snapshot of the response body
|
|
28
28
|
constructor(o, s, r, t) {
|
|
29
|
-
super(o, s, t), this.name = "FetchError", this.body =
|
|
29
|
+
super(o, s, t), this.name = "FetchError", this.body = l(r ?? void 0);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
async function b(e, o, s) {
|
|
33
33
|
const r = ` - ${e.statusText}`, t = `${o} Response status '${e.status}${e.statusText ? r : ""}' received.`;
|
|
34
|
-
let
|
|
34
|
+
let n;
|
|
35
35
|
try {
|
|
36
|
-
|
|
37
|
-
} catch (
|
|
38
|
-
|
|
36
|
+
n = await e.text();
|
|
37
|
+
} catch (u) {
|
|
38
|
+
n = `<body unavailable: ${a(u).message}>`;
|
|
39
39
|
}
|
|
40
|
-
return new i(t, s,
|
|
40
|
+
return new i(t, s, n);
|
|
41
41
|
}
|
|
42
42
|
function y(e) {
|
|
43
43
|
return e.map((o) => o.message).join(" ");
|
|
@@ -48,7 +48,7 @@ function k(e) {
|
|
|
48
48
|
} catch {
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function a(e) {
|
|
52
52
|
if (e instanceof Error) return e;
|
|
53
53
|
if (typeof e == "string") return new Error(e);
|
|
54
54
|
if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return new Error(String(e));
|
|
@@ -63,34 +63,64 @@ function n(e) {
|
|
|
63
63
|
}
|
|
64
64
|
function h(e) {
|
|
65
65
|
const o = /* @__PURE__ */ new Set(), s = [];
|
|
66
|
-
let r =
|
|
66
|
+
let r = a(e);
|
|
67
67
|
for (; r != null && !o.has(r); ) {
|
|
68
68
|
o.add(r);
|
|
69
69
|
let t;
|
|
70
|
-
|
|
70
|
+
switch (console.log("0000", r), r.name) {
|
|
71
|
+
case "APIError": {
|
|
72
|
+
const n = r;
|
|
73
|
+
t = { body: n.body, locator: n.locator, message: r.message, name: "APIError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "ConnectorError": {
|
|
77
|
+
const n = r;
|
|
78
|
+
console.log(1111, n.locator), t = { body: void 0, locator: n.locator, message: r.message, name: "ConnectorError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case "EngineError": {
|
|
82
|
+
t = { body: void 0, locator: r.locator, message: r.message, name: "EngineError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case "FetchError": {
|
|
86
|
+
const n = r;
|
|
87
|
+
t = { body: n.body, locator: n.locator, message: r.message, name: "FetchError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case "DPUError": {
|
|
91
|
+
t = { body: void 0, locator: r.locator, message: r.message, name: "DPUError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case "Error":
|
|
95
|
+
t = { body: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
96
|
+
break;
|
|
97
|
+
default:
|
|
98
|
+
t = { body: void 0, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null;
|
|
99
|
+
}
|
|
100
|
+
/(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), s.push(t);
|
|
71
101
|
}
|
|
72
102
|
return s;
|
|
73
103
|
}
|
|
74
|
-
function
|
|
104
|
+
function p(e) {
|
|
75
105
|
if (e.length === 0) return;
|
|
76
106
|
let o;
|
|
77
107
|
for (const s of e.toReversed()) {
|
|
78
108
|
let r;
|
|
79
109
|
switch (s.name) {
|
|
80
110
|
case "APIError":
|
|
81
|
-
r = new
|
|
111
|
+
r = new E(s.message, s.locator, s.body, { cause: o });
|
|
82
112
|
break;
|
|
83
113
|
case "ConnectorError":
|
|
84
|
-
console.log(2222, s.locator), r = new
|
|
114
|
+
console.log(2222, s.locator), r = new m(s.message, s.locator, { cause: o });
|
|
85
115
|
break;
|
|
86
116
|
case "EngineError":
|
|
87
|
-
r = new
|
|
117
|
+
r = new d(s.message, s.locator, { cause: o });
|
|
88
118
|
break;
|
|
89
119
|
case "FetchError":
|
|
90
120
|
r = new i(s.message, s.locator, s.body, { cause: o });
|
|
91
121
|
break;
|
|
92
122
|
case "DPUError":
|
|
93
|
-
r = new
|
|
123
|
+
r = new c(s.message, s.locator, { cause: o });
|
|
94
124
|
break;
|
|
95
125
|
default:
|
|
96
126
|
r = new Error(s.message, { cause: o }), r.name = s.name;
|
|
@@ -100,7 +130,7 @@ function w(e) {
|
|
|
100
130
|
}
|
|
101
131
|
return o;
|
|
102
132
|
}
|
|
103
|
-
function
|
|
133
|
+
function g(e) {
|
|
104
134
|
let o;
|
|
105
135
|
try {
|
|
106
136
|
o = JSON.stringify(e);
|
|
@@ -109,19 +139,20 @@ function m(e) {
|
|
|
109
139
|
}
|
|
110
140
|
return o === "" && (o = "Unknown error"), o;
|
|
111
141
|
}
|
|
112
|
-
function
|
|
142
|
+
function l(e) {
|
|
113
143
|
if (!(e == null || e === ""))
|
|
114
144
|
return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
|
|
115
145
|
}
|
|
116
146
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
147
|
+
E as APIError,
|
|
148
|
+
m as ConnectorError,
|
|
149
|
+
c as DPUError,
|
|
150
|
+
d as EngineError,
|
|
120
151
|
i as FetchError,
|
|
121
152
|
b as buildFetchError,
|
|
122
153
|
y as concatenateSerialisedErrorMessages,
|
|
123
154
|
k as ignoreErrors,
|
|
124
|
-
|
|
155
|
+
a as normalizeToError,
|
|
125
156
|
h as serialiseError,
|
|
126
|
-
|
|
157
|
+
p as unserialiseError
|
|
127
158
|
};
|
|
@@ -5,7 +5,7 @@ export interface SerialisedError {
|
|
|
5
5
|
name: string;
|
|
6
6
|
stack: string | undefined;
|
|
7
7
|
}
|
|
8
|
-
declare class DPUError extends Error {
|
|
8
|
+
export declare class DPUError extends Error {
|
|
9
9
|
readonly locator: string;
|
|
10
10
|
constructor(message: string, locator: string, options?: ErrorOptions);
|
|
11
11
|
}
|
|
@@ -51,4 +51,3 @@ export declare function serialiseError(error?: unknown): SerialisedError[];
|
|
|
51
51
|
* - Returns `undefined` if the input array is empty.
|
|
52
52
|
*/
|
|
53
53
|
export declare function unserialiseError(serialisedErrors: SerialisedError[]): Error | undefined;
|
|
54
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.566",
|
|
4
4
|
"description": "A library containing common constants, types and utilities used across all Data Positioning projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jonathan Terrell <terrell.jm@gmail.com>",
|