@datapos/datapos-shared 0.3.577 → 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 +46 -41
- package/package.json +1 -1
|
@@ -1,51 +1,51 @@
|
|
|
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,
|
|
45
|
+
return new i(t, s, n);
|
|
46
46
|
}
|
|
47
47
|
function k(e) {
|
|
48
|
-
return e.map((
|
|
48
|
+
return e.map((o) => o.message).join(" ");
|
|
49
49
|
}
|
|
50
50
|
function p(e) {
|
|
51
51
|
try {
|
|
@@ -67,17 +67,22 @@ 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
|
+
case "AppError": {
|
|
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);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
81
86
|
case "ConnectorError": {
|
|
82
87
|
t = { body: void 0, locator: r.locator, message: r.message, name: "ConnectorError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
|
|
83
88
|
break;
|
|
@@ -92,46 +97,46 @@ function h(e) {
|
|
|
92
97
|
break;
|
|
93
98
|
}
|
|
94
99
|
default:
|
|
95
|
-
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:
|
|
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);
|
|
96
101
|
}
|
|
97
|
-
/(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."),
|
|
102
|
+
/(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), s.push(t);
|
|
98
103
|
}
|
|
99
|
-
return
|
|
104
|
+
return s;
|
|
100
105
|
}
|
|
101
106
|
function w(e) {
|
|
102
107
|
if (e.length === 0) return;
|
|
103
|
-
let
|
|
104
|
-
for (const
|
|
108
|
+
let o;
|
|
109
|
+
for (const s of e.toReversed()) {
|
|
105
110
|
let r;
|
|
106
|
-
switch (
|
|
111
|
+
switch (s.name) {
|
|
107
112
|
case "APIError":
|
|
108
|
-
r = new E(
|
|
113
|
+
r = new E(s.message, s.locator, s.body, { cause: o });
|
|
109
114
|
break;
|
|
110
115
|
case "ConnectorError":
|
|
111
|
-
r = new m(
|
|
116
|
+
r = new m(s.message, s.locator, { cause: o });
|
|
112
117
|
break;
|
|
113
118
|
case "EngineError":
|
|
114
|
-
r = new d(
|
|
119
|
+
r = new d(s.message, s.locator, { cause: o });
|
|
115
120
|
break;
|
|
116
121
|
case "FetchError":
|
|
117
|
-
r = new i(
|
|
122
|
+
r = new i(s.message, s.locator, s.body, { cause: o });
|
|
118
123
|
break;
|
|
119
124
|
default:
|
|
120
|
-
r = new Error(
|
|
125
|
+
r = new Error(s.message, { cause: o }), r.name = s.name;
|
|
121
126
|
break;
|
|
122
127
|
}
|
|
123
|
-
|
|
128
|
+
s.stack !== void 0 && (r.stack = s.stack), o = r;
|
|
124
129
|
}
|
|
125
|
-
return
|
|
130
|
+
return o;
|
|
126
131
|
}
|
|
127
|
-
function
|
|
128
|
-
let
|
|
132
|
+
function g(e) {
|
|
133
|
+
let o;
|
|
129
134
|
try {
|
|
130
|
-
|
|
135
|
+
o = JSON.stringify(e);
|
|
131
136
|
} catch {
|
|
132
|
-
typeof e == "symbol" ?
|
|
137
|
+
typeof e == "symbol" ? o = e.description ?? "Unknown error" : typeof e == "bigint" ? o = e.toString() : o = "Unknown error";
|
|
133
138
|
}
|
|
134
|
-
return
|
|
139
|
+
return o === "" && (o = "Unknown error"), o;
|
|
135
140
|
}
|
|
136
141
|
function l(e) {
|
|
137
142
|
if (!(e == null || e === ""))
|
|
@@ -139,12 +144,12 @@ function l(e) {
|
|
|
139
144
|
}
|
|
140
145
|
export {
|
|
141
146
|
E as APIError,
|
|
142
|
-
|
|
147
|
+
f as AppError,
|
|
143
148
|
m as ConnectorError,
|
|
144
149
|
c as DPUError,
|
|
145
150
|
d as EngineError,
|
|
146
151
|
i as FetchError,
|
|
147
|
-
|
|
152
|
+
y as buildFetchError,
|
|
148
153
|
k as concatenateSerialisedErrorMessages,
|
|
149
154
|
p as ignoreErrors,
|
|
150
155
|
a as normalizeToError,
|
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>",
|