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