@datapos/datapos-shared 0.3.552 → 0.3.554
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 +40 -40
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
class c extends Error {
|
|
2
2
|
locator;
|
|
3
3
|
/** Logical source of the error. */
|
|
4
|
-
constructor(
|
|
5
|
-
super(
|
|
4
|
+
constructor(o, s, e) {
|
|
5
|
+
super(o, e), this.name = new.target.name, this.locator = s;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
class i extends c {
|
|
@@ -10,37 +10,37 @@ class i extends c {
|
|
|
10
10
|
class g extends i {
|
|
11
11
|
}
|
|
12
12
|
class u extends i {
|
|
13
|
-
constructor(
|
|
14
|
-
super(
|
|
13
|
+
constructor(o, s, e) {
|
|
14
|
+
super(o, s, e), this.name = "EngineError";
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
class l extends i {
|
|
18
18
|
body;
|
|
19
19
|
/** Sanitized HTTP response body. */
|
|
20
|
-
constructor(
|
|
21
|
-
super(
|
|
20
|
+
constructor(o, s, e, n) {
|
|
21
|
+
super(o, s, n), this.name = new.target.name, this.body = d(e ?? void 0);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
async function y(r,
|
|
25
|
-
const e = ` - ${r.statusText}`,
|
|
24
|
+
async function y(r, o, s) {
|
|
25
|
+
const e = ` - ${r.statusText}`, n = `${o} Response status '${r.status}${r.statusText ? e : ""}' received.`;
|
|
26
26
|
let a;
|
|
27
27
|
try {
|
|
28
28
|
a = await r.text();
|
|
29
29
|
} catch (f) {
|
|
30
|
-
a = `<body unavailable: ${
|
|
30
|
+
a = `<body unavailable: ${t(f).message}>`;
|
|
31
31
|
}
|
|
32
|
-
return new l(
|
|
32
|
+
return new l(n, s, a);
|
|
33
33
|
}
|
|
34
34
|
function b(r) {
|
|
35
|
-
return r.map((
|
|
35
|
+
return r.map((o) => o.message).join(" ");
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function k(r) {
|
|
38
38
|
try {
|
|
39
39
|
r();
|
|
40
40
|
} catch {
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function t(r) {
|
|
44
44
|
if (r instanceof Error) return r;
|
|
45
45
|
if (typeof r == "string") return new Error(r);
|
|
46
46
|
if (typeof r == "number" || typeof r == "boolean" || typeof r == "bigint") return new Error(String(r));
|
|
@@ -53,32 +53,32 @@ function n(r) {
|
|
|
53
53
|
}
|
|
54
54
|
return new Error("Unknown error");
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
let e =
|
|
59
|
-
for (; e != null && !
|
|
60
|
-
|
|
61
|
-
let
|
|
62
|
-
e instanceof l ? (
|
|
56
|
+
function w(r) {
|
|
57
|
+
const o = /* @__PURE__ */ new Set(), s = [];
|
|
58
|
+
let e = t(r);
|
|
59
|
+
for (; e != null && !o.has(e); ) {
|
|
60
|
+
o.add(e);
|
|
61
|
+
let n;
|
|
62
|
+
e instanceof l ? (n = { body: e.body, locator: e.locator, message: e.message, name: "FetchError", stack: e.stack }, e = e.cause == null ? null : t(e.cause)) : e instanceof u ? (n = { body: void 0, locator: e.locator, message: e.message, name: "EngineError", stack: e.stack }, e = e.cause == null ? null : t(e.cause)) : e instanceof c ? (n = { body: void 0, locator: e.locator, message: e.message, name: "DataPosError", stack: e.stack }, e = e.cause == null ? null : t(e.cause)) : e instanceof Error ? (n = { body: void 0, locator: "", message: e.message, name: e.name, stack: e.stack }, e = e.cause == null ? null : t(e.cause)) : (n = { body: void 0, locator: "", message: E(e), name: "Error", stack: void 0 }, e = null), /(?:\.{3}|[.!?])$/.test(n.message) || (n.message += "."), s.push(n);
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return s;
|
|
65
65
|
}
|
|
66
66
|
function h(r) {
|
|
67
67
|
if (r.length === 0) return;
|
|
68
|
-
let
|
|
69
|
-
for (const
|
|
68
|
+
let o;
|
|
69
|
+
for (const s of r.toReversed()) {
|
|
70
70
|
let e;
|
|
71
|
-
if (console.log(1111,
|
|
72
|
-
console.log("FetchError"
|
|
73
|
-
else if (
|
|
74
|
-
console.log("Generic"
|
|
71
|
+
if (console.log(1111, s), s.body !== void 0)
|
|
72
|
+
console.log("FetchError"), e = new l(s.message, s.locator, s.body, { cause: o });
|
|
73
|
+
else if (s.locator === "")
|
|
74
|
+
console.log("Generic"), e = new Error(s.message, { cause: o }), e.name = s.name;
|
|
75
75
|
else
|
|
76
|
-
switch (
|
|
76
|
+
switch (s.name) {
|
|
77
77
|
case "APIError":
|
|
78
|
-
console.log("APIError"
|
|
78
|
+
console.log("APIError"), e = new g(s.message, s.locator, { cause: o });
|
|
79
79
|
break;
|
|
80
80
|
case "EngineError":
|
|
81
|
-
|
|
81
|
+
e = new u(s.message, s.locator, { cause: o }), console.log("EngineError", e);
|
|
82
82
|
break;
|
|
83
83
|
// case 'ApplicationError':
|
|
84
84
|
// error = new ApplicationError(serialised.message, serialised.locator, { rebuiltError });
|
|
@@ -93,21 +93,21 @@ function h(r) {
|
|
|
93
93
|
// error = new WindowHandledPromiseRejectionError(serialised.message, serialised.locator, { rebuiltError });
|
|
94
94
|
// break;
|
|
95
95
|
default:
|
|
96
|
-
console.log("Fallback"
|
|
96
|
+
console.log("Fallback"), e = new c(s.message, s.locator, { cause: o });
|
|
97
97
|
break;
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
s.stack !== void 0 && (e.stack = s.stack), o = e;
|
|
100
100
|
}
|
|
101
|
-
return
|
|
101
|
+
return o;
|
|
102
102
|
}
|
|
103
103
|
function E(r) {
|
|
104
|
-
let
|
|
104
|
+
let o;
|
|
105
105
|
try {
|
|
106
|
-
|
|
106
|
+
o = JSON.stringify(r);
|
|
107
107
|
} catch {
|
|
108
|
-
typeof r == "symbol" ?
|
|
108
|
+
typeof r == "symbol" ? o = r.description ?? "Unknown error" : typeof r == "bigint" ? o = r.toString() : o = "Unknown error";
|
|
109
109
|
}
|
|
110
|
-
return
|
|
110
|
+
return o === "" && (o = "Unknown error"), o;
|
|
111
111
|
}
|
|
112
112
|
function d(r) {
|
|
113
113
|
if (!(r == null || r === ""))
|
|
@@ -119,8 +119,8 @@ export {
|
|
|
119
119
|
l as FetchError,
|
|
120
120
|
y as buildFetchError,
|
|
121
121
|
b as concatenateSerialisedErrorMessages,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
k as ignoreErrors,
|
|
123
|
+
t as normalizeToError,
|
|
124
|
+
w as serialiseError,
|
|
125
125
|
h as unserialiseError
|
|
126
126
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.554",
|
|
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>",
|