@datapos/datapos-shared 0.3.565 → 0.3.567
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/dist/datapos-shared-errors.es.js +86 -57
- package/package.json +1 -1
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
class
|
|
1
|
+
class c extends Error {
|
|
2
2
|
locator;
|
|
3
3
|
// Logical source of the error
|
|
4
|
-
constructor(
|
|
5
|
-
super(
|
|
4
|
+
constructor(s, o, r) {
|
|
5
|
+
super(s, r), this.name = "DPUError", this.locator = o;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
class
|
|
8
|
+
class E extends c {
|
|
9
9
|
body;
|
|
10
10
|
// Sanitized snapshot of the response body
|
|
11
|
-
constructor(
|
|
12
|
-
super(
|
|
11
|
+
constructor(s, o, r, t) {
|
|
12
|
+
super(s, o, t), this.name = "APIError", this.body = l(r ?? void 0);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
class
|
|
16
|
-
constructor(
|
|
17
|
-
super(
|
|
15
|
+
class d extends c {
|
|
16
|
+
constructor(s, o, r) {
|
|
17
|
+
super(s, o, r), this.name = "EngineError";
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
class
|
|
21
|
-
constructor(
|
|
22
|
-
super(
|
|
20
|
+
class m extends c {
|
|
21
|
+
constructor(s, o, r) {
|
|
22
|
+
super(s, o, 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
|
-
constructor(
|
|
29
|
-
super(
|
|
28
|
+
constructor(s, o, r, t) {
|
|
29
|
+
super(s, o, t), this.name = "FetchError", this.body = l(r ?? void 0);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
async function
|
|
33
|
-
const r = ` - ${e.statusText}`, t = `${
|
|
34
|
-
let
|
|
32
|
+
async function y(e, s, o) {
|
|
33
|
+
const r = ` - ${e.statusText}`, t = `${s} Response status '${e.status}${e.statusText ? r : ""}' received.`;
|
|
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,
|
|
40
|
+
return new i(t, o, n);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return e.map((
|
|
42
|
+
function b(e) {
|
|
43
|
+
return e.map((s) => s.message).join(" ");
|
|
44
44
|
}
|
|
45
45
|
function k(e) {
|
|
46
46
|
try {
|
|
@@ -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));
|
|
@@ -62,67 +62,96 @@ function n(e) {
|
|
|
62
62
|
return new Error("Unknown error");
|
|
63
63
|
}
|
|
64
64
|
function h(e) {
|
|
65
|
-
const
|
|
66
|
-
let r =
|
|
67
|
-
for (; r != null && !
|
|
68
|
-
|
|
65
|
+
const s = /* @__PURE__ */ new Set(), o = [];
|
|
66
|
+
let r = a(e);
|
|
67
|
+
for (; r != null && !s.has(r); ) {
|
|
68
|
+
s.add(r);
|
|
69
69
|
let t;
|
|
70
|
-
|
|
70
|
+
switch (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
|
+
t = { body: void 0, locator: r.locator, message: r.message, name: "ConnectorError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "EngineError": {
|
|
81
|
+
t = { body: void 0, locator: r.locator, message: r.message, name: "EngineError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "FetchError": {
|
|
85
|
+
const n = r;
|
|
86
|
+
t = { body: n.body, locator: n.locator, message: r.message, name: "FetchError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case "DPUError": {
|
|
90
|
+
t = { body: void 0, locator: r.locator, message: r.message, name: "DPUError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "Error":
|
|
94
|
+
t = { body: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
t = { body: void 0, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null;
|
|
98
|
+
}
|
|
99
|
+
/(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), o.push(t);
|
|
71
100
|
}
|
|
72
|
-
return
|
|
101
|
+
return console.log(4444, o), o;
|
|
73
102
|
}
|
|
74
|
-
function
|
|
103
|
+
function p(e) {
|
|
75
104
|
if (e.length === 0) return;
|
|
76
|
-
let
|
|
77
|
-
for (const
|
|
105
|
+
let s;
|
|
106
|
+
for (const o of e.toReversed()) {
|
|
78
107
|
let r;
|
|
79
|
-
switch (
|
|
108
|
+
switch (o.name) {
|
|
80
109
|
case "APIError":
|
|
81
|
-
r = new
|
|
110
|
+
r = new E(o.message, o.locator, o.body, { cause: s });
|
|
82
111
|
break;
|
|
83
112
|
case "ConnectorError":
|
|
84
|
-
|
|
113
|
+
r = new m(o.message, o.locator, { cause: s });
|
|
85
114
|
break;
|
|
86
115
|
case "EngineError":
|
|
87
|
-
r = new
|
|
116
|
+
r = new d(o.message, o.locator, { cause: s });
|
|
88
117
|
break;
|
|
89
118
|
case "FetchError":
|
|
90
|
-
r = new i(
|
|
119
|
+
r = new i(o.message, o.locator, o.body, { cause: s });
|
|
91
120
|
break;
|
|
92
121
|
case "DPUError":
|
|
93
|
-
r = new
|
|
122
|
+
r = new c(o.message, o.locator, { cause: s });
|
|
94
123
|
break;
|
|
95
124
|
default:
|
|
96
|
-
r = new Error(
|
|
125
|
+
console.log(5555, o), r = new Error(o.message, { cause: s }), r.name = o.name;
|
|
97
126
|
break;
|
|
98
127
|
}
|
|
99
|
-
|
|
128
|
+
o.stack !== void 0 && (r.stack = o.stack), s = r;
|
|
100
129
|
}
|
|
101
|
-
return
|
|
130
|
+
return s;
|
|
102
131
|
}
|
|
103
|
-
function
|
|
104
|
-
let
|
|
132
|
+
function g(e) {
|
|
133
|
+
let s;
|
|
105
134
|
try {
|
|
106
|
-
|
|
135
|
+
s = JSON.stringify(e);
|
|
107
136
|
} catch {
|
|
108
|
-
typeof e == "symbol" ?
|
|
137
|
+
typeof e == "symbol" ? s = e.description ?? "Unknown error" : typeof e == "bigint" ? s = e.toString() : s = "Unknown error";
|
|
109
138
|
}
|
|
110
|
-
return
|
|
139
|
+
return s === "" && (s = "Unknown error"), s;
|
|
111
140
|
}
|
|
112
|
-
function
|
|
141
|
+
function l(e) {
|
|
113
142
|
if (!(e == null || e === ""))
|
|
114
143
|
return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
|
|
115
144
|
}
|
|
116
145
|
export {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
146
|
+
E as APIError,
|
|
147
|
+
m as ConnectorError,
|
|
148
|
+
c as DPUError,
|
|
149
|
+
d as EngineError,
|
|
121
150
|
i as FetchError,
|
|
122
|
-
|
|
123
|
-
|
|
151
|
+
y as buildFetchError,
|
|
152
|
+
b as concatenateSerialisedErrorMessages,
|
|
124
153
|
k as ignoreErrors,
|
|
125
|
-
|
|
154
|
+
a as normalizeToError,
|
|
126
155
|
h as serialiseError,
|
|
127
|
-
|
|
156
|
+
p as unserialiseError
|
|
128
157
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.567",
|
|
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>",
|