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