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