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