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