@datapos/datapos-shared 0.3.545 → 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.
|
@@ -1,145 +1,123 @@
|
|
|
1
|
-
class
|
|
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
|
-
class
|
|
8
|
+
class i extends c {
|
|
9
9
|
}
|
|
10
|
-
class f extends
|
|
10
|
+
class f extends i {
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class d extends i {
|
|
13
13
|
}
|
|
14
|
-
class l extends
|
|
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
|
-
|
|
22
|
-
}
|
|
23
|
-
class y extends s {
|
|
24
|
-
componentName;
|
|
25
|
-
/** Vue component name, if available. */
|
|
26
|
-
info;
|
|
27
|
-
/** Vue error info string. */
|
|
28
|
-
constructor(o, n, e, t, a) {
|
|
29
|
-
super(o, n, a), this.name = new.target.name, this.info = e, this.componentName = t;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
class b extends s {
|
|
33
|
-
}
|
|
34
|
-
class k extends s {
|
|
35
|
-
}
|
|
36
|
-
async function p(r, o, n) {
|
|
37
|
-
const e = ` - ${r.statusText}`, t = `${o} Response status '${r.status}${r.statusText ? e : ""}' received.`;
|
|
21
|
+
async function y(e, t, o) {
|
|
22
|
+
const r = ` - ${e.statusText}`, s = `${t} Response status '${e.status}${e.statusText ? r : ""}' received.`;
|
|
38
23
|
let a;
|
|
39
24
|
try {
|
|
40
|
-
a = await
|
|
41
|
-
} catch (
|
|
42
|
-
a = `<body unavailable: ${
|
|
25
|
+
a = await e.text();
|
|
26
|
+
} catch (u) {
|
|
27
|
+
a = `<body unavailable: ${n(u).message}>`;
|
|
43
28
|
}
|
|
44
|
-
return new l(
|
|
29
|
+
return new l(s, o, a);
|
|
45
30
|
}
|
|
46
|
-
function
|
|
47
|
-
return
|
|
31
|
+
function w(e) {
|
|
32
|
+
return e.map((t) => t.message).join(" ");
|
|
48
33
|
}
|
|
49
|
-
function
|
|
34
|
+
function b(e) {
|
|
50
35
|
try {
|
|
51
|
-
|
|
36
|
+
e();
|
|
52
37
|
} catch {
|
|
53
38
|
}
|
|
54
39
|
}
|
|
55
|
-
function
|
|
56
|
-
if (
|
|
57
|
-
if (typeof
|
|
58
|
-
if (typeof
|
|
59
|
-
if (typeof
|
|
60
|
-
if (typeof
|
|
40
|
+
function n(e) {
|
|
41
|
+
if (e instanceof Error) return e;
|
|
42
|
+
if (typeof e == "string") return new Error(e);
|
|
43
|
+
if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return new Error(String(e));
|
|
44
|
+
if (typeof e == "symbol") return new Error(e.description ?? "Unknown error");
|
|
45
|
+
if (typeof e == "object")
|
|
61
46
|
try {
|
|
62
|
-
return new Error(JSON.stringify(
|
|
47
|
+
return new Error(JSON.stringify(e));
|
|
63
48
|
} catch {
|
|
64
49
|
return new Error("Unknown error");
|
|
65
50
|
}
|
|
66
51
|
return new Error("Unknown error");
|
|
67
52
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
let
|
|
71
|
-
for (;
|
|
72
|
-
|
|
73
|
-
let
|
|
74
|
-
|
|
53
|
+
function k(e) {
|
|
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);
|
|
75
60
|
}
|
|
76
|
-
return
|
|
61
|
+
return o;
|
|
77
62
|
}
|
|
78
|
-
function
|
|
79
|
-
if (
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.log(
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
else if (n.locator === "")
|
|
88
|
-
e = new Error(n.message, { cause: o }), e.name = n.name;
|
|
63
|
+
function h(e) {
|
|
64
|
+
if (e.length === 0) return;
|
|
65
|
+
let t;
|
|
66
|
+
for (const o of e.toReversed()) {
|
|
67
|
+
let r;
|
|
68
|
+
if (console.log(1111, o), o.body !== void 0)
|
|
69
|
+
r = new l(o.message, o.locator, o.body, { cause: t });
|
|
70
|
+
else if (o.locator === "")
|
|
71
|
+
r = new Error(o.message, { cause: t }), r.name = o.name;
|
|
89
72
|
else
|
|
90
|
-
switch (
|
|
73
|
+
switch (o.name) {
|
|
91
74
|
case "APIError":
|
|
92
|
-
|
|
75
|
+
r = new f(o.message, o.locator, { cause: t });
|
|
93
76
|
break;
|
|
94
77
|
case "EngineError":
|
|
95
|
-
|
|
96
|
-
break;
|
|
97
|
-
case "ApplicationError":
|
|
98
|
-
e = new s(n.message, n.locator, { cause: o });
|
|
99
|
-
break;
|
|
100
|
-
case "OperationalError":
|
|
101
|
-
e = new m(n.message, n.locator, { cause: o });
|
|
78
|
+
r = new d(o.message, o.locator, { cause: t });
|
|
102
79
|
break;
|
|
80
|
+
// case 'ApplicationError':
|
|
81
|
+
// error = new ApplicationError(serialised.message, serialised.locator, { rebuiltError });
|
|
82
|
+
// break;
|
|
83
|
+
// case 'OperationalError':
|
|
84
|
+
// error = new OperationalError(serialised.message, serialised.locator, { rebuiltError });
|
|
85
|
+
// break;
|
|
103
86
|
// case 'WindowHandledRuntimeError':
|
|
104
|
-
// error = new WindowHandledRuntimeError(serialised.message, serialised.locator, {
|
|
87
|
+
// error = new WindowHandledRuntimeError(serialised.message, serialised.locator, { rebuiltError });
|
|
105
88
|
// break;
|
|
106
89
|
// case 'WindowHandledPromiseRejectionError':
|
|
107
|
-
// error = new WindowHandledPromiseRejectionError(serialised.message, serialised.locator, {
|
|
90
|
+
// error = new WindowHandledPromiseRejectionError(serialised.message, serialised.locator, { rebuiltError });
|
|
108
91
|
// break;
|
|
109
92
|
default:
|
|
110
|
-
|
|
93
|
+
r = new c(o.message, o.locator, { cause: t });
|
|
111
94
|
break;
|
|
112
95
|
}
|
|
113
|
-
|
|
96
|
+
o.stack !== void 0 && (r.stack = o.stack), t = r;
|
|
114
97
|
}
|
|
115
|
-
return
|
|
98
|
+
return t;
|
|
116
99
|
}
|
|
117
|
-
function
|
|
118
|
-
let
|
|
100
|
+
function E(e) {
|
|
101
|
+
let t;
|
|
119
102
|
try {
|
|
120
|
-
|
|
103
|
+
t = JSON.stringify(e);
|
|
121
104
|
} catch {
|
|
122
|
-
typeof
|
|
105
|
+
typeof e == "symbol" ? t = e.description ?? "Unknown error" : typeof e == "bigint" ? t = e.toString() : t = "Unknown error";
|
|
123
106
|
}
|
|
124
|
-
return
|
|
107
|
+
return t === "" && (t = "Unknown error"), t;
|
|
125
108
|
}
|
|
126
|
-
function
|
|
127
|
-
if (!(
|
|
128
|
-
return
|
|
109
|
+
function g(e) {
|
|
110
|
+
if (!(e == null || e === ""))
|
|
111
|
+
return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
|
|
129
112
|
}
|
|
130
113
|
export {
|
|
131
114
|
f as APIError,
|
|
132
|
-
|
|
133
|
-
u as EngineError,
|
|
115
|
+
d as EngineError,
|
|
134
116
|
l as FetchError,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
h as
|
|
141
|
-
x as ignoreErrors,
|
|
142
|
-
c as normalizeToError,
|
|
143
|
-
R as serialiseError,
|
|
144
|
-
O as unserialiseError
|
|
117
|
+
y as buildFetchError,
|
|
118
|
+
w as concatenateSerialisedErrorMessages,
|
|
119
|
+
b as ignoreErrors,
|
|
120
|
+
n as normalizeToError,
|
|
121
|
+
k as serialiseError,
|
|
122
|
+
h as unserialiseError
|
|
145
123
|
};
|
|
@@ -38,23 +38,6 @@ declare class FetchError extends ApplicationError {
|
|
|
38
38
|
readonly body: string | undefined; /** Sanitized HTTP response body. */
|
|
39
39
|
constructor(message: string, locator: string, body?: string | null, options?: ErrorOptions);
|
|
40
40
|
}
|
|
41
|
-
/** Represents operational failures not caused by application logic. */
|
|
42
|
-
declare class OperationalError extends DataPosError {
|
|
43
|
-
}
|
|
44
|
-
/** Represents Vue errors that have been explicitly handled.
|
|
45
|
-
* Used when capturing Vue error handler output with additional component context.
|
|
46
|
-
*/
|
|
47
|
-
declare class VueHandledError extends ApplicationError {
|
|
48
|
-
readonly componentName: string | undefined; /** Vue component name, if available. */
|
|
49
|
-
readonly info: string; /** Vue error info string. */
|
|
50
|
-
constructor(message: string, locator: string, info: string, componentName?: string, options?: ErrorOptions);
|
|
51
|
-
}
|
|
52
|
-
/** Represents handled window runtime errors. */
|
|
53
|
-
declare class WindowHandledRuntimeError extends ApplicationError {
|
|
54
|
-
}
|
|
55
|
-
/** Represents handled window promise rejection errors. */
|
|
56
|
-
declare class WindowHandledPromiseRejectionError extends ApplicationError {
|
|
57
|
-
}
|
|
58
41
|
/** Builds a {@link FetchError} from an HTTP response.
|
|
59
42
|
* The response body is eagerly read so it can be included in error logs even after the response stream is closed.
|
|
60
43
|
*/
|
|
@@ -84,5 +67,5 @@ declare function serialiseError(error?: unknown): SerialisedError[];
|
|
|
84
67
|
*/
|
|
85
68
|
declare function unserialiseError(serialisedErrors: SerialisedError[]): Error | undefined;
|
|
86
69
|
export type { SerialisedError };
|
|
87
|
-
export {
|
|
70
|
+
export { APIError, EngineError, FetchError };
|
|
88
71
|
export { buildFetchError, concatenateSerialisedErrorMessages, ignoreErrors, normalizeToError, serialiseError, unserialiseError };
|
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>",
|