@datapos/datapos-shared 0.3.566 → 0.3.568
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 +41 -42
- package/package.json +1 -1
|
@@ -1,46 +1,46 @@
|
|
|
1
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
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
15
|
class d extends c {
|
|
16
|
-
constructor(
|
|
17
|
-
super(
|
|
16
|
+
constructor(s, o, r) {
|
|
17
|
+
super(s, o, r), this.name = "EngineError";
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
class m extends c {
|
|
21
|
-
constructor(
|
|
22
|
-
super(
|
|
21
|
+
constructor(s, o, r) {
|
|
22
|
+
super(s, o, r), this.name = "ConnectorError";
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
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 = `${
|
|
32
|
+
async function y(e, s, o) {
|
|
33
|
+
const r = ` - ${e.statusText}`, t = `${s} Response status '${e.status}${e.statusText ? r : ""}' received.`;
|
|
34
34
|
let n;
|
|
35
35
|
try {
|
|
36
36
|
n = await e.text();
|
|
37
37
|
} catch (u) {
|
|
38
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 {
|
|
@@ -62,20 +62,19 @@ function a(e) {
|
|
|
62
62
|
return new Error("Unknown error");
|
|
63
63
|
}
|
|
64
64
|
function h(e) {
|
|
65
|
-
const
|
|
65
|
+
const s = /* @__PURE__ */ new Set(), o = [];
|
|
66
66
|
let r = a(e);
|
|
67
|
-
for (; r != null && !
|
|
68
|
-
|
|
67
|
+
for (; r != null && !s.has(r); ) {
|
|
68
|
+
s.add(r);
|
|
69
69
|
let t;
|
|
70
|
-
switch (
|
|
70
|
+
switch (r.name) {
|
|
71
71
|
case "APIError": {
|
|
72
72
|
const n = r;
|
|
73
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
74
|
break;
|
|
75
75
|
}
|
|
76
76
|
case "ConnectorError": {
|
|
77
|
-
|
|
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);
|
|
77
|
+
t = { body: void 0, locator: r.locator, message: r.message, name: "ConnectorError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
79
78
|
break;
|
|
80
79
|
}
|
|
81
80
|
case "EngineError": {
|
|
@@ -92,52 +91,52 @@ function h(e) {
|
|
|
92
91
|
break;
|
|
93
92
|
}
|
|
94
93
|
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);
|
|
94
|
+
console.log(7777, r), t = { body: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
96
95
|
break;
|
|
97
96
|
default:
|
|
98
|
-
t = { body: void 0, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null;
|
|
97
|
+
console.log(8888, r), t = { body: void 0, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null;
|
|
99
98
|
}
|
|
100
|
-
/(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."),
|
|
99
|
+
/(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), o.push(t);
|
|
101
100
|
}
|
|
102
|
-
return
|
|
101
|
+
return console.log(4444, o), o;
|
|
103
102
|
}
|
|
104
103
|
function p(e) {
|
|
105
104
|
if (e.length === 0) return;
|
|
106
|
-
let
|
|
107
|
-
for (const
|
|
105
|
+
let s;
|
|
106
|
+
for (const o of e.toReversed()) {
|
|
108
107
|
let r;
|
|
109
|
-
switch (
|
|
108
|
+
switch (o.name) {
|
|
110
109
|
case "APIError":
|
|
111
|
-
r = new E(
|
|
110
|
+
r = new E(o.message, o.locator, o.body, { cause: s });
|
|
112
111
|
break;
|
|
113
112
|
case "ConnectorError":
|
|
114
|
-
|
|
113
|
+
r = new m(o.message, o.locator, { cause: s });
|
|
115
114
|
break;
|
|
116
115
|
case "EngineError":
|
|
117
|
-
r = new d(
|
|
116
|
+
r = new d(o.message, o.locator, { cause: s });
|
|
118
117
|
break;
|
|
119
118
|
case "FetchError":
|
|
120
|
-
r = new i(
|
|
119
|
+
r = new i(o.message, o.locator, o.body, { cause: s });
|
|
121
120
|
break;
|
|
122
121
|
case "DPUError":
|
|
123
|
-
r = new c(
|
|
122
|
+
r = new c(o.message, o.locator, { cause: s });
|
|
124
123
|
break;
|
|
125
124
|
default:
|
|
126
|
-
r = new Error(
|
|
125
|
+
console.log(5555, o), r = new Error(o.message, { cause: s }), r.name = o.name;
|
|
127
126
|
break;
|
|
128
127
|
}
|
|
129
|
-
|
|
128
|
+
o.stack !== void 0 && (r.stack = o.stack), s = r;
|
|
130
129
|
}
|
|
131
|
-
return
|
|
130
|
+
return s;
|
|
132
131
|
}
|
|
133
132
|
function g(e) {
|
|
134
|
-
let
|
|
133
|
+
let s;
|
|
135
134
|
try {
|
|
136
|
-
|
|
135
|
+
s = JSON.stringify(e);
|
|
137
136
|
} catch {
|
|
138
|
-
typeof e == "symbol" ?
|
|
137
|
+
typeof e == "symbol" ? s = e.description ?? "Unknown error" : typeof e == "bigint" ? s = e.toString() : s = "Unknown error";
|
|
139
138
|
}
|
|
140
|
-
return
|
|
139
|
+
return s === "" && (s = "Unknown error"), s;
|
|
141
140
|
}
|
|
142
141
|
function l(e) {
|
|
143
142
|
if (!(e == null || e === ""))
|
|
@@ -149,8 +148,8 @@ export {
|
|
|
149
148
|
c as DPUError,
|
|
150
149
|
d as EngineError,
|
|
151
150
|
i as FetchError,
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
y as buildFetchError,
|
|
152
|
+
b as concatenateSerialisedErrorMessages,
|
|
154
153
|
k as ignoreErrors,
|
|
155
154
|
a as normalizeToError,
|
|
156
155
|
h as serialiseError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.568",
|
|
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>",
|