@datapos/datapos-shared 0.3.559 → 0.3.561
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.
|
@@ -8,8 +8,8 @@ class a extends Error {
|
|
|
8
8
|
class l extends a {
|
|
9
9
|
body;
|
|
10
10
|
// Sanitized snapshot of the response body
|
|
11
|
-
constructor(o, s, r,
|
|
12
|
-
super(o, s,
|
|
11
|
+
constructor(o, s, r, t) {
|
|
12
|
+
super(o, s, t), this.name = "APIError", this.body = E(r ?? void 0);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
class u extends a {
|
|
@@ -17,29 +17,27 @@ class u extends a {
|
|
|
17
17
|
super(o, s, r), this.name = "EngineError";
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
class
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
constructor(o, s, r, n) {
|
|
24
|
-
super(o, s, n), this.name = "ConnectorError", this.id = r;
|
|
20
|
+
class f extends a {
|
|
21
|
+
constructor(o, s, r) {
|
|
22
|
+
super(o, s, r), this.name = "ConnectorError";
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
class i extends a {
|
|
28
26
|
body;
|
|
29
27
|
// Sanitized snapshot of the response body
|
|
30
|
-
constructor(o, s, r,
|
|
31
|
-
super(o, s,
|
|
28
|
+
constructor(o, s, r, t) {
|
|
29
|
+
super(o, s, t), this.name = "FetchError", this.body = E(r ?? void 0);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
async function b(e, o, s) {
|
|
35
|
-
const r = ` - ${e.statusText}`,
|
|
33
|
+
const r = ` - ${e.statusText}`, t = `${o} Response status '${e.status}${e.statusText ? r : ""}' received.`;
|
|
36
34
|
let c;
|
|
37
35
|
try {
|
|
38
36
|
c = await e.text();
|
|
39
|
-
} catch (
|
|
40
|
-
c = `<body unavailable: ${
|
|
37
|
+
} catch (d) {
|
|
38
|
+
c = `<body unavailable: ${n(d).message}>`;
|
|
41
39
|
}
|
|
42
|
-
return new i(
|
|
40
|
+
return new i(t, s, c);
|
|
43
41
|
}
|
|
44
42
|
function y(e) {
|
|
45
43
|
return e.map((o) => o.message).join(" ");
|
|
@@ -50,7 +48,7 @@ function k(e) {
|
|
|
50
48
|
} catch {
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
function
|
|
51
|
+
function n(e) {
|
|
54
52
|
if (e instanceof Error) return e;
|
|
55
53
|
if (typeof e == "string") return new Error(e);
|
|
56
54
|
if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return new Error(String(e));
|
|
@@ -65,15 +63,15 @@ function t(e) {
|
|
|
65
63
|
}
|
|
66
64
|
function h(e) {
|
|
67
65
|
const o = /* @__PURE__ */ new Set(), s = [];
|
|
68
|
-
let r =
|
|
66
|
+
let r = n(e);
|
|
69
67
|
for (; r != null && !o.has(r); ) {
|
|
70
68
|
o.add(r);
|
|
71
|
-
let
|
|
72
|
-
r instanceof l ? (
|
|
69
|
+
let t;
|
|
70
|
+
r instanceof l ? (t = { body: r.body, locator: r.locator, message: r.message, name: "APIError", stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : r instanceof f ? (t = { body: void 0, locator: r.locator, message: r.message, name: "ConnectorError", stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : r instanceof u ? (t = { body: void 0, locator: r.locator, message: r.message, name: "EngineError", stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : r instanceof i ? (t = { body: r.body, locator: r.locator, message: r.message, name: "FetchError", stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : r instanceof a ? (t = { body: void 0, locator: r.locator, message: r.message, name: "DPUError", stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : r instanceof Error ? (t = { body: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : (t = { body: void 0, locator: "", message: m(r), name: "Error", stack: void 0 }, r = null), /(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), s.push(t);
|
|
73
71
|
}
|
|
74
72
|
return s;
|
|
75
73
|
}
|
|
76
|
-
function
|
|
74
|
+
function w(e) {
|
|
77
75
|
if (e.length === 0) return;
|
|
78
76
|
let o;
|
|
79
77
|
for (const s of e.toReversed()) {
|
|
@@ -83,7 +81,7 @@ function p(e) {
|
|
|
83
81
|
r = new l(s.message, s.locator, s.body, { cause: o });
|
|
84
82
|
break;
|
|
85
83
|
case "ConnectorError":
|
|
86
|
-
r = new
|
|
84
|
+
r = new f(s.message, s.locator, { cause: o });
|
|
87
85
|
break;
|
|
88
86
|
case "EngineError":
|
|
89
87
|
r = new u(s.message, s.locator, { cause: o });
|
|
@@ -102,7 +100,7 @@ function p(e) {
|
|
|
102
100
|
}
|
|
103
101
|
return o;
|
|
104
102
|
}
|
|
105
|
-
function
|
|
103
|
+
function m(e) {
|
|
106
104
|
let o;
|
|
107
105
|
try {
|
|
108
106
|
o = JSON.stringify(e);
|
|
@@ -111,19 +109,19 @@ function E(e) {
|
|
|
111
109
|
}
|
|
112
110
|
return o === "" && (o = "Unknown error"), o;
|
|
113
111
|
}
|
|
114
|
-
function
|
|
112
|
+
function E(e) {
|
|
115
113
|
if (!(e == null || e === ""))
|
|
116
114
|
return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
|
|
117
115
|
}
|
|
118
116
|
export {
|
|
119
117
|
l as APIError,
|
|
120
|
-
|
|
118
|
+
f as ConnectorError,
|
|
121
119
|
u as EngineError,
|
|
122
120
|
i as FetchError,
|
|
123
121
|
b as buildFetchError,
|
|
124
122
|
y as concatenateSerialisedErrorMessages,
|
|
125
123
|
k as ignoreErrors,
|
|
126
|
-
|
|
124
|
+
n as normalizeToError,
|
|
127
125
|
h as serialiseError,
|
|
128
|
-
|
|
126
|
+
w as unserialiseError
|
|
129
127
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export interface SerialisedError {
|
|
2
2
|
body: string | undefined;
|
|
3
|
-
componentId: string | undefined;
|
|
4
3
|
locator: string;
|
|
5
4
|
message: string;
|
|
6
5
|
name: string;
|
|
@@ -18,8 +17,7 @@ export declare class EngineError extends DPUError {
|
|
|
18
17
|
constructor(message: string, locator: string, options?: ErrorOptions);
|
|
19
18
|
}
|
|
20
19
|
export declare class ConnectorError extends DPUError {
|
|
21
|
-
|
|
22
|
-
constructor(message: string, locator: string, id: string | undefined, options?: ErrorOptions);
|
|
20
|
+
constructor(message: string, locator: string, options?: ErrorOptions);
|
|
23
21
|
}
|
|
24
22
|
export declare class FetchError extends DPUError {
|
|
25
23
|
readonly body: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.561",
|
|
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>",
|