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