@nice-code/error 0.2.8 → 0.2.10
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/README.md +237 -5
- package/build/index.js +19 -2891
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,2891 +1,19 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var METHOD_NOT_ALLOWED = 405;
|
|
21
|
-
var MOVED_PERMANENTLY = 301;
|
|
22
|
-
var MOVED_TEMPORARILY = 302;
|
|
23
|
-
var MULTI_STATUS = 207;
|
|
24
|
-
var MULTIPLE_CHOICES = 300;
|
|
25
|
-
var NETWORK_AUTHENTICATION_REQUIRED = 511;
|
|
26
|
-
var NO_CONTENT = 204;
|
|
27
|
-
var NON_AUTHORITATIVE_INFORMATION = 203;
|
|
28
|
-
var NOT_ACCEPTABLE = 406;
|
|
29
|
-
var NOT_FOUND = 404;
|
|
30
|
-
var NOT_IMPLEMENTED = 501;
|
|
31
|
-
var NOT_MODIFIED = 304;
|
|
32
|
-
var OK = 200;
|
|
33
|
-
var PARTIAL_CONTENT = 206;
|
|
34
|
-
var PAYMENT_REQUIRED = 402;
|
|
35
|
-
var PERMANENT_REDIRECT = 308;
|
|
36
|
-
var PRECONDITION_FAILED = 412;
|
|
37
|
-
var PRECONDITION_REQUIRED = 428;
|
|
38
|
-
var PROCESSING = 102;
|
|
39
|
-
var PROXY_AUTHENTICATION_REQUIRED = 407;
|
|
40
|
-
var REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
|
|
41
|
-
var REQUEST_TIMEOUT = 408;
|
|
42
|
-
var REQUEST_TOO_LONG = 413;
|
|
43
|
-
var REQUEST_URI_TOO_LONG = 414;
|
|
44
|
-
var REQUESTED_RANGE_NOT_SATISFIABLE = 416;
|
|
45
|
-
var RESET_CONTENT = 205;
|
|
46
|
-
var SEE_OTHER = 303;
|
|
47
|
-
var SERVICE_UNAVAILABLE = 503;
|
|
48
|
-
var SWITCHING_PROTOCOLS = 101;
|
|
49
|
-
var TEMPORARY_REDIRECT = 307;
|
|
50
|
-
var TOO_MANY_REQUESTS = 429;
|
|
51
|
-
var UNAUTHORIZED = 401;
|
|
52
|
-
var UNPROCESSABLE_ENTITY = 422;
|
|
53
|
-
var UNSUPPORTED_MEDIA_TYPE = 415;
|
|
54
|
-
var USE_PROXY = 305;
|
|
55
|
-
var legacy_default = {
|
|
56
|
-
ACCEPTED,
|
|
57
|
-
BAD_GATEWAY,
|
|
58
|
-
BAD_REQUEST,
|
|
59
|
-
CONFLICT,
|
|
60
|
-
CONTINUE,
|
|
61
|
-
CREATED,
|
|
62
|
-
EXPECTATION_FAILED,
|
|
63
|
-
FORBIDDEN,
|
|
64
|
-
GATEWAY_TIMEOUT,
|
|
65
|
-
GONE,
|
|
66
|
-
HTTP_VERSION_NOT_SUPPORTED,
|
|
67
|
-
IM_A_TEAPOT,
|
|
68
|
-
INSUFFICIENT_SPACE_ON_RESOURCE,
|
|
69
|
-
INSUFFICIENT_STORAGE,
|
|
70
|
-
INTERNAL_SERVER_ERROR,
|
|
71
|
-
LENGTH_REQUIRED,
|
|
72
|
-
LOCKED,
|
|
73
|
-
METHOD_FAILURE,
|
|
74
|
-
METHOD_NOT_ALLOWED,
|
|
75
|
-
MOVED_PERMANENTLY,
|
|
76
|
-
MOVED_TEMPORARILY,
|
|
77
|
-
MULTI_STATUS,
|
|
78
|
-
MULTIPLE_CHOICES,
|
|
79
|
-
NETWORK_AUTHENTICATION_REQUIRED,
|
|
80
|
-
NO_CONTENT,
|
|
81
|
-
NON_AUTHORITATIVE_INFORMATION,
|
|
82
|
-
NOT_ACCEPTABLE,
|
|
83
|
-
NOT_FOUND,
|
|
84
|
-
NOT_IMPLEMENTED,
|
|
85
|
-
NOT_MODIFIED,
|
|
86
|
-
OK,
|
|
87
|
-
PARTIAL_CONTENT,
|
|
88
|
-
PAYMENT_REQUIRED,
|
|
89
|
-
PERMANENT_REDIRECT,
|
|
90
|
-
PRECONDITION_FAILED,
|
|
91
|
-
PRECONDITION_REQUIRED,
|
|
92
|
-
PROCESSING,
|
|
93
|
-
PROXY_AUTHENTICATION_REQUIRED,
|
|
94
|
-
REQUEST_HEADER_FIELDS_TOO_LARGE,
|
|
95
|
-
REQUEST_TIMEOUT,
|
|
96
|
-
REQUEST_TOO_LONG,
|
|
97
|
-
REQUEST_URI_TOO_LONG,
|
|
98
|
-
REQUESTED_RANGE_NOT_SATISFIABLE,
|
|
99
|
-
RESET_CONTENT,
|
|
100
|
-
SEE_OTHER,
|
|
101
|
-
SERVICE_UNAVAILABLE,
|
|
102
|
-
SWITCHING_PROTOCOLS,
|
|
103
|
-
TEMPORARY_REDIRECT,
|
|
104
|
-
TOO_MANY_REQUESTS,
|
|
105
|
-
UNAUTHORIZED,
|
|
106
|
-
UNPROCESSABLE_ENTITY,
|
|
107
|
-
UNSUPPORTED_MEDIA_TYPE,
|
|
108
|
-
USE_PROXY
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// ../../node_modules/.bun/http-status-codes@2.3.0/node_modules/http-status-codes/build/es/utils.js
|
|
112
|
-
var statusCodeToReasonPhrase = {
|
|
113
|
-
"202": "Accepted",
|
|
114
|
-
"502": "Bad Gateway",
|
|
115
|
-
"400": "Bad Request",
|
|
116
|
-
"409": "Conflict",
|
|
117
|
-
"100": "Continue",
|
|
118
|
-
"201": "Created",
|
|
119
|
-
"417": "Expectation Failed",
|
|
120
|
-
"424": "Failed Dependency",
|
|
121
|
-
"403": "Forbidden",
|
|
122
|
-
"504": "Gateway Timeout",
|
|
123
|
-
"410": "Gone",
|
|
124
|
-
"505": "HTTP Version Not Supported",
|
|
125
|
-
"418": "I'm a teapot",
|
|
126
|
-
"419": "Insufficient Space on Resource",
|
|
127
|
-
"507": "Insufficient Storage",
|
|
128
|
-
"500": "Internal Server Error",
|
|
129
|
-
"411": "Length Required",
|
|
130
|
-
"423": "Locked",
|
|
131
|
-
"420": "Method Failure",
|
|
132
|
-
"405": "Method Not Allowed",
|
|
133
|
-
"301": "Moved Permanently",
|
|
134
|
-
"302": "Moved Temporarily",
|
|
135
|
-
"207": "Multi-Status",
|
|
136
|
-
"300": "Multiple Choices",
|
|
137
|
-
"511": "Network Authentication Required",
|
|
138
|
-
"204": "No Content",
|
|
139
|
-
"203": "Non Authoritative Information",
|
|
140
|
-
"406": "Not Acceptable",
|
|
141
|
-
"404": "Not Found",
|
|
142
|
-
"501": "Not Implemented",
|
|
143
|
-
"304": "Not Modified",
|
|
144
|
-
"200": "OK",
|
|
145
|
-
"206": "Partial Content",
|
|
146
|
-
"402": "Payment Required",
|
|
147
|
-
"308": "Permanent Redirect",
|
|
148
|
-
"412": "Precondition Failed",
|
|
149
|
-
"428": "Precondition Required",
|
|
150
|
-
"102": "Processing",
|
|
151
|
-
"103": "Early Hints",
|
|
152
|
-
"426": "Upgrade Required",
|
|
153
|
-
"407": "Proxy Authentication Required",
|
|
154
|
-
"431": "Request Header Fields Too Large",
|
|
155
|
-
"408": "Request Timeout",
|
|
156
|
-
"413": "Request Entity Too Large",
|
|
157
|
-
"414": "Request-URI Too Long",
|
|
158
|
-
"416": "Requested Range Not Satisfiable",
|
|
159
|
-
"205": "Reset Content",
|
|
160
|
-
"303": "See Other",
|
|
161
|
-
"503": "Service Unavailable",
|
|
162
|
-
"101": "Switching Protocols",
|
|
163
|
-
"307": "Temporary Redirect",
|
|
164
|
-
"429": "Too Many Requests",
|
|
165
|
-
"401": "Unauthorized",
|
|
166
|
-
"451": "Unavailable For Legal Reasons",
|
|
167
|
-
"422": "Unprocessable Entity",
|
|
168
|
-
"415": "Unsupported Media Type",
|
|
169
|
-
"305": "Use Proxy",
|
|
170
|
-
"421": "Misdirected Request"
|
|
171
|
-
};
|
|
172
|
-
var reasonPhraseToStatusCode = {
|
|
173
|
-
Accepted: 202,
|
|
174
|
-
"Bad Gateway": 502,
|
|
175
|
-
"Bad Request": 400,
|
|
176
|
-
Conflict: 409,
|
|
177
|
-
Continue: 100,
|
|
178
|
-
Created: 201,
|
|
179
|
-
"Expectation Failed": 417,
|
|
180
|
-
"Failed Dependency": 424,
|
|
181
|
-
Forbidden: 403,
|
|
182
|
-
"Gateway Timeout": 504,
|
|
183
|
-
Gone: 410,
|
|
184
|
-
"HTTP Version Not Supported": 505,
|
|
185
|
-
"I'm a teapot": 418,
|
|
186
|
-
"Insufficient Space on Resource": 419,
|
|
187
|
-
"Insufficient Storage": 507,
|
|
188
|
-
"Internal Server Error": 500,
|
|
189
|
-
"Length Required": 411,
|
|
190
|
-
Locked: 423,
|
|
191
|
-
"Method Failure": 420,
|
|
192
|
-
"Method Not Allowed": 405,
|
|
193
|
-
"Moved Permanently": 301,
|
|
194
|
-
"Moved Temporarily": 302,
|
|
195
|
-
"Multi-Status": 207,
|
|
196
|
-
"Multiple Choices": 300,
|
|
197
|
-
"Network Authentication Required": 511,
|
|
198
|
-
"No Content": 204,
|
|
199
|
-
"Non Authoritative Information": 203,
|
|
200
|
-
"Not Acceptable": 406,
|
|
201
|
-
"Not Found": 404,
|
|
202
|
-
"Not Implemented": 501,
|
|
203
|
-
"Not Modified": 304,
|
|
204
|
-
OK: 200,
|
|
205
|
-
"Partial Content": 206,
|
|
206
|
-
"Payment Required": 402,
|
|
207
|
-
"Permanent Redirect": 308,
|
|
208
|
-
"Precondition Failed": 412,
|
|
209
|
-
"Precondition Required": 428,
|
|
210
|
-
Processing: 102,
|
|
211
|
-
"Early Hints": 103,
|
|
212
|
-
"Upgrade Required": 426,
|
|
213
|
-
"Proxy Authentication Required": 407,
|
|
214
|
-
"Request Header Fields Too Large": 431,
|
|
215
|
-
"Request Timeout": 408,
|
|
216
|
-
"Request Entity Too Large": 413,
|
|
217
|
-
"Request-URI Too Long": 414,
|
|
218
|
-
"Requested Range Not Satisfiable": 416,
|
|
219
|
-
"Reset Content": 205,
|
|
220
|
-
"See Other": 303,
|
|
221
|
-
"Service Unavailable": 503,
|
|
222
|
-
"Switching Protocols": 101,
|
|
223
|
-
"Temporary Redirect": 307,
|
|
224
|
-
"Too Many Requests": 429,
|
|
225
|
-
Unauthorized: 401,
|
|
226
|
-
"Unavailable For Legal Reasons": 451,
|
|
227
|
-
"Unprocessable Entity": 422,
|
|
228
|
-
"Unsupported Media Type": 415,
|
|
229
|
-
"Use Proxy": 305,
|
|
230
|
-
"Misdirected Request": 421
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
// ../../node_modules/.bun/http-status-codes@2.3.0/node_modules/http-status-codes/build/es/utils-functions.js
|
|
234
|
-
function getReasonPhrase(statusCode) {
|
|
235
|
-
var result = statusCodeToReasonPhrase[statusCode.toString()];
|
|
236
|
-
if (!result) {
|
|
237
|
-
throw new Error("Status code does not exist: " + statusCode);
|
|
238
|
-
}
|
|
239
|
-
return result;
|
|
240
|
-
}
|
|
241
|
-
function getStatusCode(reasonPhrase) {
|
|
242
|
-
var result = reasonPhraseToStatusCode[reasonPhrase];
|
|
243
|
-
if (!result) {
|
|
244
|
-
throw new Error("Reason phrase does not exist: " + reasonPhrase);
|
|
245
|
-
}
|
|
246
|
-
return result;
|
|
247
|
-
}
|
|
248
|
-
var getStatusText = getReasonPhrase;
|
|
249
|
-
|
|
250
|
-
// ../../node_modules/.bun/http-status-codes@2.3.0/node_modules/http-status-codes/build/es/status-codes.js
|
|
251
|
-
var StatusCodes;
|
|
252
|
-
(function(StatusCodes2) {
|
|
253
|
-
StatusCodes2[StatusCodes2["CONTINUE"] = 100] = "CONTINUE";
|
|
254
|
-
StatusCodes2[StatusCodes2["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
255
|
-
StatusCodes2[StatusCodes2["PROCESSING"] = 102] = "PROCESSING";
|
|
256
|
-
StatusCodes2[StatusCodes2["EARLY_HINTS"] = 103] = "EARLY_HINTS";
|
|
257
|
-
StatusCodes2[StatusCodes2["OK"] = 200] = "OK";
|
|
258
|
-
StatusCodes2[StatusCodes2["CREATED"] = 201] = "CREATED";
|
|
259
|
-
StatusCodes2[StatusCodes2["ACCEPTED"] = 202] = "ACCEPTED";
|
|
260
|
-
StatusCodes2[StatusCodes2["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
261
|
-
StatusCodes2[StatusCodes2["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
262
|
-
StatusCodes2[StatusCodes2["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
263
|
-
StatusCodes2[StatusCodes2["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
264
|
-
StatusCodes2[StatusCodes2["MULTI_STATUS"] = 207] = "MULTI_STATUS";
|
|
265
|
-
StatusCodes2[StatusCodes2["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
|
|
266
|
-
StatusCodes2[StatusCodes2["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
267
|
-
StatusCodes2[StatusCodes2["MOVED_TEMPORARILY"] = 302] = "MOVED_TEMPORARILY";
|
|
268
|
-
StatusCodes2[StatusCodes2["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
269
|
-
StatusCodes2[StatusCodes2["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
270
|
-
StatusCodes2[StatusCodes2["USE_PROXY"] = 305] = "USE_PROXY";
|
|
271
|
-
StatusCodes2[StatusCodes2["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
272
|
-
StatusCodes2[StatusCodes2["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
273
|
-
StatusCodes2[StatusCodes2["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
274
|
-
StatusCodes2[StatusCodes2["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
275
|
-
StatusCodes2[StatusCodes2["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
276
|
-
StatusCodes2[StatusCodes2["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
277
|
-
StatusCodes2[StatusCodes2["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
278
|
-
StatusCodes2[StatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
279
|
-
StatusCodes2[StatusCodes2["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
280
|
-
StatusCodes2[StatusCodes2["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
281
|
-
StatusCodes2[StatusCodes2["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
282
|
-
StatusCodes2[StatusCodes2["CONFLICT"] = 409] = "CONFLICT";
|
|
283
|
-
StatusCodes2[StatusCodes2["GONE"] = 410] = "GONE";
|
|
284
|
-
StatusCodes2[StatusCodes2["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
285
|
-
StatusCodes2[StatusCodes2["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
286
|
-
StatusCodes2[StatusCodes2["REQUEST_TOO_LONG"] = 413] = "REQUEST_TOO_LONG";
|
|
287
|
-
StatusCodes2[StatusCodes2["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
|
|
288
|
-
StatusCodes2[StatusCodes2["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
289
|
-
StatusCodes2[StatusCodes2["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
290
|
-
StatusCodes2[StatusCodes2["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
291
|
-
StatusCodes2[StatusCodes2["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
|
|
292
|
-
StatusCodes2[StatusCodes2["INSUFFICIENT_SPACE_ON_RESOURCE"] = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE";
|
|
293
|
-
StatusCodes2[StatusCodes2["METHOD_FAILURE"] = 420] = "METHOD_FAILURE";
|
|
294
|
-
StatusCodes2[StatusCodes2["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
|
|
295
|
-
StatusCodes2[StatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
296
|
-
StatusCodes2[StatusCodes2["LOCKED"] = 423] = "LOCKED";
|
|
297
|
-
StatusCodes2[StatusCodes2["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
298
|
-
StatusCodes2[StatusCodes2["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
|
|
299
|
-
StatusCodes2[StatusCodes2["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
300
|
-
StatusCodes2[StatusCodes2["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
301
|
-
StatusCodes2[StatusCodes2["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
302
|
-
StatusCodes2[StatusCodes2["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
303
|
-
StatusCodes2[StatusCodes2["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
304
|
-
StatusCodes2[StatusCodes2["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
305
|
-
StatusCodes2[StatusCodes2["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
306
|
-
StatusCodes2[StatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
307
|
-
StatusCodes2[StatusCodes2["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
308
|
-
StatusCodes2[StatusCodes2["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
309
|
-
StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
310
|
-
StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
311
|
-
})(StatusCodes || (StatusCodes = {}));
|
|
312
|
-
// ../../node_modules/.bun/http-status-codes@2.3.0/node_modules/http-status-codes/build/es/index.js
|
|
313
|
-
var __assign = function() {
|
|
314
|
-
__assign = Object.assign || function(t) {
|
|
315
|
-
for (var s, i = 1, n = arguments.length;i < n; i++) {
|
|
316
|
-
s = arguments[i];
|
|
317
|
-
for (var p in s)
|
|
318
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
319
|
-
t[p] = s[p];
|
|
320
|
-
}
|
|
321
|
-
return t;
|
|
322
|
-
};
|
|
323
|
-
return __assign.apply(this, arguments);
|
|
324
|
-
};
|
|
325
|
-
var es_default = __assign(__assign({}, legacy_default), {
|
|
326
|
-
getStatusCode,
|
|
327
|
-
getStatusText
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
// src/utils/jsErrorOrCastJsError.ts
|
|
331
|
-
function jsErrorOrCastJsError(error, logMessage = true) {
|
|
332
|
-
if (error instanceof Error) {
|
|
333
|
-
return Object.assign(error, {
|
|
334
|
-
message: error.message
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
const message = error?.message ?? (typeof error === "string" ? error : "No error message found");
|
|
338
|
-
if (logMessage) {
|
|
339
|
-
console.error(`An unknown and unstructured error was thrown: ${message}`, error);
|
|
340
|
-
}
|
|
341
|
-
return {
|
|
342
|
-
...new Error(message),
|
|
343
|
-
...error
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// src/NiceError/nice_error.static.ts
|
|
348
|
-
var DUR_OBJ_PACK_PREFIX = "NE_DUROBJ[[";
|
|
349
|
-
var DUR_OBJ_PACK_SUFFIX = "]]NE_DUROBJ";
|
|
350
|
-
|
|
351
|
-
// src/utils/packError/packError.enums.ts
|
|
352
|
-
var EErrorPackType;
|
|
353
|
-
((EErrorPackType2) => {
|
|
354
|
-
EErrorPackType2["no_pack"] = "no_pack";
|
|
355
|
-
EErrorPackType2["msg_pack"] = "msg_pack";
|
|
356
|
-
EErrorPackType2["cause_pack"] = "cause_pack";
|
|
357
|
-
})(EErrorPackType ||= {});
|
|
358
|
-
|
|
359
|
-
// src/utils/packError/causePack.ts
|
|
360
|
-
var causePack = (error) => {
|
|
361
|
-
error._packedState = { cause: error.cause, packedAs: "cause_pack" /* cause_pack */ };
|
|
362
|
-
error.cause = `${DUR_OBJ_PACK_PREFIX}${JSON.stringify(error.toJsonObject())}${DUR_OBJ_PACK_SUFFIX}`;
|
|
363
|
-
return error;
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
// src/utils/packError/msgPack.ts
|
|
367
|
-
var msgPack = (error) => {
|
|
368
|
-
error._packedState = { message: error.cleanMessage, packedAs: "msg_pack" /* msg_pack */ };
|
|
369
|
-
error.message = `${DUR_OBJ_PACK_PREFIX}${JSON.stringify(error.toJsonObject())}${DUR_OBJ_PACK_SUFFIX}`;
|
|
370
|
-
return error;
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
// src/utils/packError/packError.ts
|
|
374
|
-
var packError = (error, packType = "msg_pack") => {
|
|
375
|
-
if (packType === "no_pack") {
|
|
376
|
-
return error;
|
|
377
|
-
}
|
|
378
|
-
if (packType === "msg_pack") {
|
|
379
|
-
return msgPack(error);
|
|
380
|
-
}
|
|
381
|
-
return causePack(error);
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
// src/NiceError/NiceError.ts
|
|
385
|
-
class NiceError extends Error {
|
|
386
|
-
name = "NiceError";
|
|
387
|
-
def;
|
|
388
|
-
ids;
|
|
389
|
-
wasntNice;
|
|
390
|
-
httpStatusCode;
|
|
391
|
-
timeCreated;
|
|
392
|
-
cleanMessage;
|
|
393
|
-
originError;
|
|
394
|
-
_packedState;
|
|
395
|
-
_errorDataMap;
|
|
396
|
-
constructor(options) {
|
|
397
|
-
const messagePure = options.message;
|
|
398
|
-
const prefixedMessage = `[${options.def.domain}](${options.ids.join(",")}) ${messagePure}`;
|
|
399
|
-
super(prefixedMessage);
|
|
400
|
-
this.cleanMessage = messagePure;
|
|
401
|
-
this.def = options.def;
|
|
402
|
-
this.ids = options.ids;
|
|
403
|
-
this._errorDataMap = options.errorData;
|
|
404
|
-
this.wasntNice = options.wasntNice ?? false;
|
|
405
|
-
this.httpStatusCode = options.httpStatusCode ?? 500;
|
|
406
|
-
if (options.originError != null) {
|
|
407
|
-
this.originError = options.originError;
|
|
408
|
-
}
|
|
409
|
-
this.timeCreated = options.timeCreated ?? Date.now();
|
|
410
|
-
}
|
|
411
|
-
hasId(id) {
|
|
412
|
-
return id in this._errorDataMap;
|
|
413
|
-
}
|
|
414
|
-
hasOneOfIds(ids) {
|
|
415
|
-
return ids.some((id) => (id in this._errorDataMap));
|
|
416
|
-
}
|
|
417
|
-
get hasMultiple() {
|
|
418
|
-
return Object.keys(this._errorDataMap).length > 1;
|
|
419
|
-
}
|
|
420
|
-
getIds() {
|
|
421
|
-
return Object.keys(this._errorDataMap);
|
|
422
|
-
}
|
|
423
|
-
getContext(id) {
|
|
424
|
-
const errorData = this._errorDataMap[id];
|
|
425
|
-
const state = errorData?.contextState;
|
|
426
|
-
if (state == null) {
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
if (state.kind === "unhydrated") {
|
|
430
|
-
throw new Error(`[NiceError.getContext] Context for id "${String(id)}" is in the "unhydrated" state. ` + `The error was reconstructed from a serialized payload but has not been deserialized yet. ` + `Call \`niceErrorDefined.hydrate(error)\` to reconstruct the typed context.`);
|
|
431
|
-
}
|
|
432
|
-
return state.value;
|
|
433
|
-
}
|
|
434
|
-
getErrorDataForId(id) {
|
|
435
|
-
return this._errorDataMap[id];
|
|
436
|
-
}
|
|
437
|
-
withOriginError(error) {
|
|
438
|
-
this.originError = jsErrorOrCastJsError(error);
|
|
439
|
-
if (this._packedState?.packedAs !== "cause_pack" /* cause_pack */) {
|
|
440
|
-
this.cause = this.originError;
|
|
441
|
-
}
|
|
442
|
-
return this;
|
|
443
|
-
}
|
|
444
|
-
matches(other) {
|
|
445
|
-
const myDef = this.def;
|
|
446
|
-
const otherDef = other.def;
|
|
447
|
-
if (myDef.domain !== otherDef.domain)
|
|
448
|
-
return false;
|
|
449
|
-
const myIds = this.getIds().map(String).sort();
|
|
450
|
-
const otherIds = other.getIds().map(String).sort();
|
|
451
|
-
if (myIds.length !== otherIds.length)
|
|
452
|
-
return false;
|
|
453
|
-
return myIds.every((id, i) => id === otherIds[i]);
|
|
454
|
-
}
|
|
455
|
-
toJsonObject() {
|
|
456
|
-
const originError = this.originError ? {
|
|
457
|
-
name: this.originError.name,
|
|
458
|
-
message: this.originError.cleanMessage ?? this.originError.message,
|
|
459
|
-
stack: this.originError.stack,
|
|
460
|
-
cause: this.originError.cause
|
|
461
|
-
} : undefined;
|
|
462
|
-
const def = {
|
|
463
|
-
domain: this.def.domain,
|
|
464
|
-
allDomains: this.def.allDomains
|
|
465
|
-
};
|
|
466
|
-
if (this.def.defaultHttpStatusCode != null) {
|
|
467
|
-
def["defaultHttpStatusCode"] = this.def.defaultHttpStatusCode;
|
|
468
|
-
}
|
|
469
|
-
if (this.def.defaultMessage != null) {
|
|
470
|
-
def["defaultMessage"] = this.def.defaultMessage;
|
|
471
|
-
}
|
|
472
|
-
const errorData = {};
|
|
473
|
-
for (const rawId of Object.keys(this._errorDataMap)) {
|
|
474
|
-
const id = rawId;
|
|
475
|
-
const data = this._errorDataMap[id];
|
|
476
|
-
if (data == null)
|
|
477
|
-
continue;
|
|
478
|
-
let contextState;
|
|
479
|
-
if (data.contextState.kind === "hydrated" /* hydrated */) {
|
|
480
|
-
contextState = {
|
|
481
|
-
kind: "unhydrated" /* unhydrated */,
|
|
482
|
-
serialized: data.contextState.serialized
|
|
483
|
-
};
|
|
484
|
-
} else {
|
|
485
|
-
contextState = data.contextState;
|
|
486
|
-
}
|
|
487
|
-
errorData[id] = {
|
|
488
|
-
contextState,
|
|
489
|
-
message: data.cleanMessage ?? data.message,
|
|
490
|
-
httpStatusCode: data.httpStatusCode,
|
|
491
|
-
timeAdded: data.timeAdded
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
return {
|
|
495
|
-
name: "NiceError",
|
|
496
|
-
def,
|
|
497
|
-
ids: this.ids,
|
|
498
|
-
errorData,
|
|
499
|
-
wasntNice: this.wasntNice,
|
|
500
|
-
message: this.cleanMessage,
|
|
501
|
-
httpStatusCode: this.httpStatusCode,
|
|
502
|
-
timeCreated: this.timeCreated,
|
|
503
|
-
...this.stack != null ? { stack: this.stack } : {},
|
|
504
|
-
originError
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
toJsonString() {
|
|
508
|
-
return JSON.stringify(this.toJsonObject());
|
|
509
|
-
}
|
|
510
|
-
toHttpResponse() {
|
|
511
|
-
return new Response(this.toJsonString(), {
|
|
512
|
-
status: this.httpStatusCode,
|
|
513
|
-
headers: { "Content-Type": "application/json" }
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
hydrate(definedNiceError) {
|
|
517
|
-
return definedNiceError.hydrate(this);
|
|
518
|
-
}
|
|
519
|
-
handleWithSync(handlerInput, handlerOptions = {}) {
|
|
520
|
-
const handlersArray = Array.isArray(handlerInput) ? handlerInput : [handlerInput];
|
|
521
|
-
for (const handler of handlersArray) {
|
|
522
|
-
const result = handler.handleErrorWithPromiseInspection(this, handlerOptions);
|
|
523
|
-
if (result.matched) {
|
|
524
|
-
if (result.isPromise) {
|
|
525
|
-
console.warn(`[NiceError.handleWith] Handler ${result.target.identifier} returned a Promise but was called via \`handleWith\` (synchronous). ` + `The Promise will not be awaited. Use \`handleWithAsync\` for async handlers.`);
|
|
526
|
-
}
|
|
527
|
-
return result.isPromise ? undefined : result.handlerResponse;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
if (handlerOptions.throwOnUnhandled === true)
|
|
531
|
-
throw this;
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
async handleWithAsync(handlerInput, handlerOptions = {}) {
|
|
535
|
-
const handlersArray = Array.isArray(handlerInput) ? handlerInput : [handlerInput];
|
|
536
|
-
for (const handler of handlersArray) {
|
|
537
|
-
const result = handler.handleErrorWithPromiseInspection(this, handlerOptions);
|
|
538
|
-
if (result.matched) {
|
|
539
|
-
return result.isPromise ? await result.handlerPromise : result.handlerResponse;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
if (handlerOptions.throwOnUnhandled === true)
|
|
543
|
-
throw this;
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
get isPacked() {
|
|
547
|
-
return this._packedState != null;
|
|
548
|
-
}
|
|
549
|
-
pack(packType = "msg_pack") {
|
|
550
|
-
if (this.isPacked)
|
|
551
|
-
return this;
|
|
552
|
-
return packError(this, packType);
|
|
553
|
-
}
|
|
554
|
-
unpack() {
|
|
555
|
-
if (this._packedState == null)
|
|
556
|
-
return this;
|
|
557
|
-
if (this._packedState.packedAs === "msg_pack" /* msg_pack */) {
|
|
558
|
-
this.message = this._packedState.message;
|
|
559
|
-
}
|
|
560
|
-
if (this._packedState.packedAs === "cause_pack" /* cause_pack */) {
|
|
561
|
-
this.cause = this._packedState.cause;
|
|
562
|
-
}
|
|
563
|
-
this._packedState = undefined;
|
|
564
|
-
delete this._packedState;
|
|
565
|
-
return this;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// src/NiceError/NiceErrorHydrated.ts
|
|
570
|
-
class NiceErrorHydrated extends NiceError {
|
|
571
|
-
def;
|
|
572
|
-
niceErrorDefined;
|
|
573
|
-
constructor(options) {
|
|
574
|
-
super(options);
|
|
575
|
-
this.def = options.def;
|
|
576
|
-
this.niceErrorDefined = options.niceErrorDefined;
|
|
577
|
-
}
|
|
578
|
-
addContext(context) {
|
|
579
|
-
const newIds = Object.keys(context);
|
|
580
|
-
const newErrorData = {};
|
|
581
|
-
for (const id of newIds) {
|
|
582
|
-
newErrorData[id] = this.niceErrorDefined.reconcileErrorDataForId(id, context[id]);
|
|
583
|
-
}
|
|
584
|
-
const mergedErrorData = {
|
|
585
|
-
...this._errorDataMap,
|
|
586
|
-
...newErrorData
|
|
587
|
-
};
|
|
588
|
-
const mergedIds = Array.from(new Set([...this.getIds(), ...Object.keys(context)]));
|
|
589
|
-
return new NiceErrorHydrated({
|
|
590
|
-
def: this.def,
|
|
591
|
-
niceErrorDefined: this.niceErrorDefined,
|
|
592
|
-
ids: mergedIds,
|
|
593
|
-
errorData: mergedErrorData,
|
|
594
|
-
message: this.cleanMessage,
|
|
595
|
-
wasntNice: this.wasntNice,
|
|
596
|
-
httpStatusCode: this.httpStatusCode,
|
|
597
|
-
originError: this.originError
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
addId(...args) {
|
|
601
|
-
const [id, context] = args;
|
|
602
|
-
const reconciledData = this.niceErrorDefined.reconcileErrorDataForId(id, context);
|
|
603
|
-
const errorDataMap = {};
|
|
604
|
-
errorDataMap[id] = reconciledData;
|
|
605
|
-
const mergedContexts = {
|
|
606
|
-
...this._errorDataMap,
|
|
607
|
-
...errorDataMap
|
|
608
|
-
};
|
|
609
|
-
const mergedIds = Array.from(new Set([...this.getIds(), id]));
|
|
610
|
-
return new NiceErrorHydrated({
|
|
611
|
-
def: this.def,
|
|
612
|
-
niceErrorDefined: this.niceErrorDefined,
|
|
613
|
-
ids: mergedIds,
|
|
614
|
-
errorData: mergedContexts,
|
|
615
|
-
message: this.cleanMessage,
|
|
616
|
-
wasntNice: this.wasntNice,
|
|
617
|
-
httpStatusCode: this.httpStatusCode,
|
|
618
|
-
originError: this.originError
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
// src/NiceErrorDefined/NiceErrorDefined.ts
|
|
624
|
-
class NiceErrorDomain {
|
|
625
|
-
domain;
|
|
626
|
-
allDomains;
|
|
627
|
-
defaultHttpStatusCode;
|
|
628
|
-
defaultMessage;
|
|
629
|
-
_schema;
|
|
630
|
-
_definedChildNiceErrors = [];
|
|
631
|
-
_definedParentNiceError;
|
|
632
|
-
_setPack;
|
|
633
|
-
_packAsFn;
|
|
634
|
-
constructor(definition) {
|
|
635
|
-
this.domain = definition.domain;
|
|
636
|
-
this.allDomains = definition.allDomains;
|
|
637
|
-
this._schema = definition.schema;
|
|
638
|
-
if (definition.packAs != null) {
|
|
639
|
-
this._packAsFn = definition.packAs;
|
|
640
|
-
}
|
|
641
|
-
if (definition.defaultHttpStatusCode != null) {
|
|
642
|
-
this.defaultHttpStatusCode = definition.defaultHttpStatusCode;
|
|
643
|
-
}
|
|
644
|
-
if (definition.defaultMessage != null) {
|
|
645
|
-
this.defaultMessage = definition.defaultMessage;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
createChildDomain(subErrorDef) {
|
|
649
|
-
const child = new NiceErrorDomain({
|
|
650
|
-
domain: subErrorDef.domain,
|
|
651
|
-
allDomains: [subErrorDef.domain, ...this.allDomains],
|
|
652
|
-
schema: subErrorDef.schema,
|
|
653
|
-
defaultHttpStatusCode: subErrorDef.defaultHttpStatusCode,
|
|
654
|
-
defaultMessage: subErrorDef.defaultMessage
|
|
655
|
-
});
|
|
656
|
-
this.addChildNiceErrorDefined(child);
|
|
657
|
-
child.addParentNiceErrorDefined(this);
|
|
658
|
-
if (subErrorDef.packAs != null) {
|
|
659
|
-
child._packAsFn = subErrorDef.packAs;
|
|
660
|
-
} else if (this._setPack) {
|
|
661
|
-
child.packAs(this._setPack);
|
|
662
|
-
} else if (this._packAsFn) {
|
|
663
|
-
child._packAsFn = this._packAsFn;
|
|
664
|
-
}
|
|
665
|
-
return child;
|
|
666
|
-
}
|
|
667
|
-
addParentNiceErrorDefined(parentError) {
|
|
668
|
-
if (this._definedParentNiceError?.domain === parentError.domain) {
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
this._definedParentNiceError = {
|
|
672
|
-
domain: parentError.domain,
|
|
673
|
-
definedError: parentError
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
addChildNiceErrorDefined(child) {
|
|
677
|
-
if (this._definedChildNiceErrors.some((linked) => linked.domain === child.domain)) {
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
this._definedChildNiceErrors.push({
|
|
681
|
-
domain: child.domain,
|
|
682
|
-
definedError: child
|
|
683
|
-
});
|
|
684
|
-
if (this._definedParentNiceError) {
|
|
685
|
-
this._definedParentNiceError.definedError.addChildNiceErrorDefined(child);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
packAs(pack) {
|
|
689
|
-
this._setPack = pack;
|
|
690
|
-
return this;
|
|
691
|
-
}
|
|
692
|
-
createError(input) {
|
|
693
|
-
const err = new NiceErrorHydrated(input);
|
|
694
|
-
const packType = this._setPack ?? this._packAsFn?.();
|
|
695
|
-
if (packType != null && packType !== "no_pack") {
|
|
696
|
-
return err.pack(packType);
|
|
697
|
-
}
|
|
698
|
-
return err;
|
|
699
|
-
}
|
|
700
|
-
hydrate(error) {
|
|
701
|
-
const errDef = error.def;
|
|
702
|
-
if (errDef.domain !== this.domain) {
|
|
703
|
-
throw new Error(`[NiceErrorDefined.hydrate] Domain mismatch: this definition is "${this.domain}" ` + `but the error belongs to "${errDef.domain}". ` + `Call \`niceErrorDefined.is(error)\` before hydrating to ensure compatibility.`);
|
|
704
|
-
}
|
|
705
|
-
const finalError = error instanceof NiceError ? error : new NiceError(error);
|
|
706
|
-
const reconciledErrorData = {};
|
|
707
|
-
for (const id of finalError.getIds()) {
|
|
708
|
-
const existingData = finalError.getErrorDataForId(id);
|
|
709
|
-
if (existingData == null)
|
|
710
|
-
continue;
|
|
711
|
-
let contextState = existingData.contextState;
|
|
712
|
-
if (contextState.kind === "unhydrated") {
|
|
713
|
-
const entry = this._schema[id];
|
|
714
|
-
const deserialize = entry?.context?.serialization?.fromJsonSerializable;
|
|
715
|
-
if (deserialize != null) {
|
|
716
|
-
contextState = {
|
|
717
|
-
kind: "hydrated" /* hydrated */,
|
|
718
|
-
value: deserialize(contextState.serialized),
|
|
719
|
-
serialized: contextState.serialized
|
|
720
|
-
};
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
reconciledErrorData[id] = {
|
|
724
|
-
contextState,
|
|
725
|
-
message: existingData.cleanMessage ?? existingData.message,
|
|
726
|
-
httpStatusCode: existingData.httpStatusCode,
|
|
727
|
-
timeAdded: existingData.timeAdded
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
return new NiceErrorHydrated({
|
|
731
|
-
def: this._buildDef(),
|
|
732
|
-
niceErrorDefined: this,
|
|
733
|
-
ids: finalError.ids,
|
|
734
|
-
errorData: reconciledErrorData,
|
|
735
|
-
message: finalError.cleanMessage ?? finalError.message,
|
|
736
|
-
httpStatusCode: finalError.httpStatusCode,
|
|
737
|
-
wasntNice: finalError.wasntNice,
|
|
738
|
-
originError: finalError.originError,
|
|
739
|
-
timeCreated: finalError.timeCreated
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
fromId(...args) {
|
|
743
|
-
const [id, context] = args;
|
|
744
|
-
const reconciledData = this.reconcileErrorDataForId(id, context);
|
|
745
|
-
const errorData = {};
|
|
746
|
-
errorData[id] = reconciledData;
|
|
747
|
-
return this.createError({
|
|
748
|
-
def: this._buildDef(),
|
|
749
|
-
niceErrorDefined: this,
|
|
750
|
-
ids: [id],
|
|
751
|
-
errorData,
|
|
752
|
-
message: reconciledData.cleanMessage ?? reconciledData.message,
|
|
753
|
-
httpStatusCode: reconciledData.httpStatusCode
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
fromContext(context) {
|
|
757
|
-
const ids = Object.keys(context);
|
|
758
|
-
if (ids.length === 0) {
|
|
759
|
-
throw new Error("[NiceErrorDefined.fromContext] context object must contain at least one error id.");
|
|
760
|
-
}
|
|
761
|
-
const errorData = {};
|
|
762
|
-
for (const id of ids) {
|
|
763
|
-
errorData[id] = this.reconcileErrorDataForId(id, context[id]);
|
|
764
|
-
}
|
|
765
|
-
const primaryId = ids[0];
|
|
766
|
-
return this.createError({
|
|
767
|
-
def: this._buildDef(),
|
|
768
|
-
niceErrorDefined: this,
|
|
769
|
-
ids,
|
|
770
|
-
errorData,
|
|
771
|
-
message: errorData[primaryId].cleanMessage ?? errorData[primaryId].message,
|
|
772
|
-
httpStatusCode: errorData[primaryId].httpStatusCode
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
isExact(error) {
|
|
776
|
-
if (!(error instanceof NiceError))
|
|
777
|
-
return false;
|
|
778
|
-
const errDef = error.def;
|
|
779
|
-
return errDef.domain === this.domain;
|
|
780
|
-
}
|
|
781
|
-
isThisOrChild(error) {
|
|
782
|
-
if (!(error instanceof NiceError))
|
|
783
|
-
return false;
|
|
784
|
-
const errDef = error.def;
|
|
785
|
-
return errDef.domain === this.domain || this.allDomains.includes(errDef.domain);
|
|
786
|
-
}
|
|
787
|
-
isParentOf(target) {
|
|
788
|
-
const allDomains = target instanceof NiceError ? target.def.allDomains : target.allDomains;
|
|
789
|
-
return Array.isArray(allDomains) && allDomains.includes(this.domain);
|
|
790
|
-
}
|
|
791
|
-
_buildDef() {
|
|
792
|
-
return {
|
|
793
|
-
domain: this.domain,
|
|
794
|
-
allDomains: this.allDomains,
|
|
795
|
-
schema: this._schema
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
_resolveMessage(id, context) {
|
|
799
|
-
const entry = this._schema[id];
|
|
800
|
-
if (typeof entry?.message === "function") {
|
|
801
|
-
return entry.message(context);
|
|
802
|
-
}
|
|
803
|
-
if (typeof entry?.message === "string") {
|
|
804
|
-
return entry.message;
|
|
805
|
-
}
|
|
806
|
-
return this.defaultMessage ?? `[${this.domain}::${id}] An error occurred.`;
|
|
807
|
-
}
|
|
808
|
-
_resolveHttpStatusCode(id, context) {
|
|
809
|
-
const entry = this._schema[id];
|
|
810
|
-
let httpStatusCode;
|
|
811
|
-
if (typeof entry?.httpStatusCode === "function") {
|
|
812
|
-
httpStatusCode = entry.httpStatusCode(context);
|
|
813
|
-
}
|
|
814
|
-
if (typeof entry?.httpStatusCode === "number") {
|
|
815
|
-
httpStatusCode = entry.httpStatusCode;
|
|
816
|
-
}
|
|
817
|
-
return typeof httpStatusCode === "number" ? httpStatusCode : this.defaultHttpStatusCode ?? 500;
|
|
818
|
-
}
|
|
819
|
-
reconcileErrorDataForId(id, context) {
|
|
820
|
-
const message = this._resolveMessage(id, context);
|
|
821
|
-
const httpStatusCode = this._resolveHttpStatusCode(id, context);
|
|
822
|
-
const entry = this._schema[id];
|
|
823
|
-
let contextState;
|
|
824
|
-
if (context != null && entry?.context?.serialization != null) {
|
|
825
|
-
const serialized = entry.context.serialization.toJsonSerializable(context);
|
|
826
|
-
contextState = { kind: "hydrated" /* hydrated */, value: context, serialized };
|
|
827
|
-
} else {
|
|
828
|
-
contextState = { kind: "serde_unset" /* serde_unset */, value: context };
|
|
829
|
-
}
|
|
830
|
-
return { contextState, message, httpStatusCode, timeAdded: Date.now() };
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
// src/NiceErrorDefined/defineNiceError.ts
|
|
835
|
-
var defineNiceError = (definition) => {
|
|
836
|
-
return new NiceErrorDomain({
|
|
837
|
-
domain: definition.domain,
|
|
838
|
-
allDomains: [definition.domain],
|
|
839
|
-
schema: definition.schema,
|
|
840
|
-
...definition.packAs != null ? { packAs: definition.packAs } : {}
|
|
841
|
-
});
|
|
842
|
-
};
|
|
843
|
-
|
|
844
|
-
// src/NiceErrorDefined/err.ts
|
|
845
|
-
function err(meta) {
|
|
846
|
-
return meta ?? {};
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
// src/internal/nice_core_errors.ts
|
|
850
|
-
var err_nice = defineNiceError({
|
|
851
|
-
domain: "err_nice",
|
|
852
|
-
schema: {}
|
|
853
|
-
});
|
|
854
|
-
var EErrId_CastNotNice;
|
|
855
|
-
((EErrId_CastNotNice2) => {
|
|
856
|
-
EErrId_CastNotNice2["js_error"] = "native_error";
|
|
857
|
-
EErrId_CastNotNice2["js_error_like_object"] = "js_error_like_object";
|
|
858
|
-
EErrId_CastNotNice2["nullish_value"] = "nullish_value";
|
|
859
|
-
EErrId_CastNotNice2["js_data_type"] = "js_data_type";
|
|
860
|
-
EErrId_CastNotNice2["js_other"] = "js_other";
|
|
861
|
-
})(EErrId_CastNotNice ||= {});
|
|
862
|
-
var err_cast_not_nice = err_nice.createChildDomain({
|
|
863
|
-
domain: "err_cast_not_nice",
|
|
864
|
-
defaultHttpStatusCode: StatusCodes.UNPROCESSABLE_ENTITY,
|
|
865
|
-
schema: {
|
|
866
|
-
["native_error" /* js_error */]: err({
|
|
867
|
-
context: {
|
|
868
|
-
required: true
|
|
869
|
-
},
|
|
870
|
-
message: ({ jsError }) => `A native JavaScript Error was encountered during casting: ${jsError.message}`,
|
|
871
|
-
httpStatusCode: StatusCodes.INTERNAL_SERVER_ERROR
|
|
872
|
-
}),
|
|
873
|
-
["js_error_like_object" /* js_error_like_object */]: err({
|
|
874
|
-
context: {
|
|
875
|
-
required: true
|
|
876
|
-
},
|
|
877
|
-
message: ({ jsErrorObject }) => `An object resembling a JavaScript Error was encountered during casting: [${jsErrorObject.name}] ${jsErrorObject.message}`,
|
|
878
|
-
httpStatusCode: StatusCodes.INTERNAL_SERVER_ERROR
|
|
879
|
-
}),
|
|
880
|
-
["nullish_value" /* nullish_value */]: err({
|
|
881
|
-
context: {
|
|
882
|
-
required: true
|
|
883
|
-
},
|
|
884
|
-
message: ({ value }) => `A nullish value [${value === null ? "null" : "undefined"}] was encountered during casting`
|
|
885
|
-
}),
|
|
886
|
-
["js_data_type" /* js_data_type */]: err({
|
|
887
|
-
context: {
|
|
888
|
-
required: true
|
|
889
|
-
},
|
|
890
|
-
message: ({ jsDataType, jsDataValue }) => {
|
|
891
|
-
let inspectedValue;
|
|
892
|
-
try {
|
|
893
|
-
inspectedValue = JSON.stringify(jsDataValue);
|
|
894
|
-
} catch {}
|
|
895
|
-
return `A value of type [${jsDataType}] with value [${inspectedValue ?? "UNSERIALIZABLE"}] was encountered during casting, which is not a valid error type`;
|
|
896
|
-
}
|
|
897
|
-
}),
|
|
898
|
-
["js_other" /* js_other */]: err({
|
|
899
|
-
context: {
|
|
900
|
-
required: true
|
|
901
|
-
},
|
|
902
|
-
message: ({ jsDataValue }) => {
|
|
903
|
-
let inspectedValue;
|
|
904
|
-
try {
|
|
905
|
-
inspectedValue = JSON.stringify(jsDataValue);
|
|
906
|
-
} catch {}
|
|
907
|
-
return `An unhandled type [${typeof jsDataValue}] with value [${inspectedValue ?? "UNSERIALIZABLE"}] was encountered during casting, which is not a valid error type`;
|
|
908
|
-
}
|
|
909
|
-
})
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
var err_nice_handler = err_nice.createChildDomain({
|
|
913
|
-
domain: "err_nice_handler",
|
|
914
|
-
schema: {}
|
|
915
|
-
});
|
|
916
|
-
// src/NiceErrorHandler/NiceErrorHandler.types.ts
|
|
917
|
-
var EErrorHandlerTargetType;
|
|
918
|
-
((EErrorHandlerTargetType2) => {
|
|
919
|
-
EErrorHandlerTargetType2["ids"] = "ids";
|
|
920
|
-
EErrorHandlerTargetType2["domain"] = "domain";
|
|
921
|
-
EErrorHandlerTargetType2["default"] = "default";
|
|
922
|
-
})(EErrorHandlerTargetType ||= {});
|
|
923
|
-
|
|
924
|
-
// src/NiceErrorHandler/NiceErrorHandler.ts
|
|
925
|
-
class NiceErrorHandler {
|
|
926
|
-
handlerConfigs = [];
|
|
927
|
-
_defaultRequester;
|
|
928
|
-
handleErrorWithPromiseInspection(error, options) {
|
|
929
|
-
for (const handlerConfig of this.handlerConfigs) {
|
|
930
|
-
if (!handlerConfig._matcher(error))
|
|
931
|
-
continue;
|
|
932
|
-
const errorResult = handlerConfig._requester(error);
|
|
933
|
-
if (errorResult instanceof Promise) {
|
|
934
|
-
return {
|
|
935
|
-
isPromise: true,
|
|
936
|
-
matched: true,
|
|
937
|
-
target: handlerConfig.target,
|
|
938
|
-
handlerPromise: errorResult
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
return {
|
|
942
|
-
isPromise: false,
|
|
943
|
-
matched: true,
|
|
944
|
-
target: handlerConfig.target,
|
|
945
|
-
handlerResponse: errorResult
|
|
946
|
-
};
|
|
947
|
-
}
|
|
948
|
-
if (this._defaultRequester) {
|
|
949
|
-
const defaultResult = this._defaultRequester(error);
|
|
950
|
-
if (defaultResult instanceof Promise) {
|
|
951
|
-
return {
|
|
952
|
-
isPromise: true,
|
|
953
|
-
matched: true,
|
|
954
|
-
target: {
|
|
955
|
-
type: "default" /* default */,
|
|
956
|
-
identifier: "[matched:default]"
|
|
957
|
-
},
|
|
958
|
-
handlerPromise: defaultResult
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
return {
|
|
962
|
-
isPromise: false,
|
|
963
|
-
matched: true,
|
|
964
|
-
target: { type: "default" /* default */, identifier: "[matched:default]" },
|
|
965
|
-
handlerResponse: defaultResult
|
|
966
|
-
};
|
|
967
|
-
}
|
|
968
|
-
if (options?.throwOnUnhandled === true) {
|
|
969
|
-
throw error;
|
|
970
|
-
}
|
|
971
|
-
return {
|
|
972
|
-
matched: false,
|
|
973
|
-
attemptedTargets: this.handlerConfigs.map((config) => config.target)
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
forDomain(domain, handler) {
|
|
977
|
-
this.handlerConfigs.push({
|
|
978
|
-
target: {
|
|
979
|
-
type: "domain" /* domain */,
|
|
980
|
-
domain: domain.domain,
|
|
981
|
-
identifier: `[matched:domain:${domain.domain}]`
|
|
982
|
-
},
|
|
983
|
-
_matcher: (error) => domain.isExact(error),
|
|
984
|
-
_requester: (error) => handler(domain.hydrate(error))
|
|
985
|
-
});
|
|
986
|
-
return this;
|
|
987
|
-
}
|
|
988
|
-
forId(domain, id, handler) {
|
|
989
|
-
this.handlerConfigs.push({
|
|
990
|
-
target: {
|
|
991
|
-
type: "ids" /* ids */,
|
|
992
|
-
domain: domain.domain,
|
|
993
|
-
ids: [id],
|
|
994
|
-
identifier: `[matched:ids:${domain.domain}:${id}]`
|
|
995
|
-
},
|
|
996
|
-
_matcher: (error) => domain.isExact(error) && error.hasId(id),
|
|
997
|
-
_requester: (error) => handler(domain.hydrate(error))
|
|
998
|
-
});
|
|
999
|
-
return this;
|
|
1000
|
-
}
|
|
1001
|
-
forIds(domain, ids, handler) {
|
|
1002
|
-
this.handlerConfigs.push({
|
|
1003
|
-
target: {
|
|
1004
|
-
type: "ids" /* ids */,
|
|
1005
|
-
domain: domain.domain,
|
|
1006
|
-
ids,
|
|
1007
|
-
identifier: `[matched:ids:${domain.domain}:${ids.join(",")}]`
|
|
1008
|
-
},
|
|
1009
|
-
_matcher: (error) => domain.isExact(error) && ids.some((id) => error.hasId(id)),
|
|
1010
|
-
_requester: (error) => handler(domain.hydrate(error))
|
|
1011
|
-
});
|
|
1012
|
-
return this;
|
|
1013
|
-
}
|
|
1014
|
-
setDefaultHandler(handler) {
|
|
1015
|
-
this._defaultRequester = handler;
|
|
1016
|
-
return this;
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
// src/NiceErrorHandler/handleWith.ts
|
|
1021
|
-
function forDomain(domain, handler) {
|
|
1022
|
-
return new NiceErrorHandler().forDomain(domain, handler);
|
|
1023
|
-
}
|
|
1024
|
-
function forId(domain, id, handler) {
|
|
1025
|
-
return new NiceErrorHandler().forId(domain, id, handler);
|
|
1026
|
-
}
|
|
1027
|
-
function forIds(domain, ids, handler) {
|
|
1028
|
-
return new NiceErrorHandler().forIds(domain, ids, handler);
|
|
1029
|
-
}
|
|
1030
|
-
// src/utils/isNiceErrorObject.ts
|
|
1031
|
-
function isNiceErrorObject(obj) {
|
|
1032
|
-
if (typeof obj !== "object" || obj == null)
|
|
1033
|
-
return false;
|
|
1034
|
-
const o = obj;
|
|
1035
|
-
if (o["name"] !== "NiceError" || typeof o["message"] !== "string" || typeof o["wasntNice"] !== "boolean" || typeof o["httpStatusCode"] !== "number") {
|
|
1036
|
-
return false;
|
|
1037
|
-
}
|
|
1038
|
-
const def = o["def"];
|
|
1039
|
-
if (typeof def !== "object" || def == null)
|
|
1040
|
-
return false;
|
|
1041
|
-
const d = def;
|
|
1042
|
-
if (typeof d["domain"] !== "string" || !Array.isArray(d["allDomains"]))
|
|
1043
|
-
return false;
|
|
1044
|
-
const errorData = o["errorData"];
|
|
1045
|
-
if (errorData != null) {
|
|
1046
|
-
if (typeof errorData !== "object")
|
|
1047
|
-
return false;
|
|
1048
|
-
for (const entry of Object.values(errorData)) {
|
|
1049
|
-
if (entry == null)
|
|
1050
|
-
continue;
|
|
1051
|
-
if (typeof entry !== "object")
|
|
1052
|
-
return false;
|
|
1053
|
-
const e = entry;
|
|
1054
|
-
const state = e["contextState"];
|
|
1055
|
-
if (state == null || typeof state !== "object")
|
|
1056
|
-
return false;
|
|
1057
|
-
const kind = state["kind"];
|
|
1058
|
-
if (kind !== "serde_unset" /* serde_unset */ && kind !== "unhydrated" /* unhydrated */)
|
|
1059
|
-
return false;
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
return true;
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
// src/utils/isRegularErrorObject.ts
|
|
1066
|
-
function isRegularErrorJsonObject(obj) {
|
|
1067
|
-
if (typeof obj !== "object" || obj == null)
|
|
1068
|
-
return false;
|
|
1069
|
-
const o = obj;
|
|
1070
|
-
return typeof o["name"] === "string" && typeof o["message"] === "string";
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/urlToObj.js
|
|
1074
|
-
function urlToObject(url) {
|
|
1075
|
-
return {
|
|
1076
|
-
href: url.href,
|
|
1077
|
-
protocol: url.protocol,
|
|
1078
|
-
username: url.username,
|
|
1079
|
-
password: url.password,
|
|
1080
|
-
host: url.host,
|
|
1081
|
-
hostname: url.hostname,
|
|
1082
|
-
port: url.port,
|
|
1083
|
-
pathname: url.pathname,
|
|
1084
|
-
search: url.search,
|
|
1085
|
-
searchParams: [...url.searchParams].map(([key, value]) => ({ key, value })),
|
|
1086
|
-
hash: url.hash,
|
|
1087
|
-
origin: url.origin
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/prettyLogStyles.js
|
|
1092
|
-
var prettyLogStyles = {
|
|
1093
|
-
reset: [0, 0],
|
|
1094
|
-
bold: [1, 22],
|
|
1095
|
-
dim: [2, 22],
|
|
1096
|
-
italic: [3, 23],
|
|
1097
|
-
underline: [4, 24],
|
|
1098
|
-
overline: [53, 55],
|
|
1099
|
-
inverse: [7, 27],
|
|
1100
|
-
hidden: [8, 28],
|
|
1101
|
-
strikethrough: [9, 29],
|
|
1102
|
-
black: [30, 39],
|
|
1103
|
-
red: [31, 39],
|
|
1104
|
-
green: [32, 39],
|
|
1105
|
-
yellow: [33, 39],
|
|
1106
|
-
blue: [34, 39],
|
|
1107
|
-
magenta: [35, 39],
|
|
1108
|
-
cyan: [36, 39],
|
|
1109
|
-
white: [37, 39],
|
|
1110
|
-
blackBright: [90, 39],
|
|
1111
|
-
redBright: [91, 39],
|
|
1112
|
-
greenBright: [92, 39],
|
|
1113
|
-
yellowBright: [93, 39],
|
|
1114
|
-
blueBright: [94, 39],
|
|
1115
|
-
magentaBright: [95, 39],
|
|
1116
|
-
cyanBright: [96, 39],
|
|
1117
|
-
whiteBright: [97, 39],
|
|
1118
|
-
bgBlack: [40, 49],
|
|
1119
|
-
bgRed: [41, 49],
|
|
1120
|
-
bgGreen: [42, 49],
|
|
1121
|
-
bgYellow: [43, 49],
|
|
1122
|
-
bgBlue: [44, 49],
|
|
1123
|
-
bgMagenta: [45, 49],
|
|
1124
|
-
bgCyan: [46, 49],
|
|
1125
|
-
bgWhite: [47, 49],
|
|
1126
|
-
bgBlackBright: [100, 49],
|
|
1127
|
-
bgRedBright: [101, 49],
|
|
1128
|
-
bgGreenBright: [102, 49],
|
|
1129
|
-
bgYellowBright: [103, 49],
|
|
1130
|
-
bgBlueBright: [104, 49],
|
|
1131
|
-
bgMagentaBright: [105, 49],
|
|
1132
|
-
bgCyanBright: [106, 49],
|
|
1133
|
-
bgWhiteBright: [107, 49]
|
|
1134
|
-
};
|
|
1135
|
-
|
|
1136
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/formatTemplate.js
|
|
1137
|
-
function formatTemplate(settings, template, values, hideUnsetPlaceholder = false) {
|
|
1138
|
-
const templateString = String(template);
|
|
1139
|
-
const ansiColorWrap = (placeholderValue, code) => `\x1B[${code[0]}m${placeholderValue}\x1B[${code[1]}m`;
|
|
1140
|
-
const styleWrap = (value, style) => {
|
|
1141
|
-
if (style != null && typeof style === "string") {
|
|
1142
|
-
return ansiColorWrap(value, prettyLogStyles[style]);
|
|
1143
|
-
} else if (style != null && Array.isArray(style)) {
|
|
1144
|
-
return style.reduce((prevValue, thisStyle) => styleWrap(prevValue, thisStyle), value);
|
|
1145
|
-
} else {
|
|
1146
|
-
if (style != null && style[value.trim()] != null) {
|
|
1147
|
-
return styleWrap(value, style[value.trim()]);
|
|
1148
|
-
} else if (style != null && style["*"] != null) {
|
|
1149
|
-
return styleWrap(value, style["*"]);
|
|
1150
|
-
} else {
|
|
1151
|
-
return value;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
};
|
|
1155
|
-
const defaultStyle = null;
|
|
1156
|
-
return templateString.replace(/{{(.+?)}}/g, (_, placeholder) => {
|
|
1157
|
-
const value = values[placeholder] != null ? String(values[placeholder]) : hideUnsetPlaceholder ? "" : _;
|
|
1158
|
-
return settings.stylePrettyLogs ? styleWrap(value, settings?.prettyLogStyles?.[placeholder] ?? defaultStyle) + ansiColorWrap("", prettyLogStyles.reset) : value;
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/formatNumberAddZeros.js
|
|
1163
|
-
function formatNumberAddZeros(value, digits = 2, addNumber = 0) {
|
|
1164
|
-
if (value != null && isNaN(value)) {
|
|
1165
|
-
return "";
|
|
1166
|
-
}
|
|
1167
|
-
value = value != null ? value + addNumber : value;
|
|
1168
|
-
return digits === 2 ? value == null ? "--" : value < 10 ? "0" + value : value.toString() : value == null ? "---" : value < 10 ? "00" + value : value < 100 ? "0" + value : value.toString();
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/internal/metaFormatting.js
|
|
1172
|
-
function buildPrettyMeta(settings, meta) {
|
|
1173
|
-
if (meta == null) {
|
|
1174
|
-
return {
|
|
1175
|
-
text: "",
|
|
1176
|
-
template: settings.prettyLogTemplate,
|
|
1177
|
-
placeholders: {}
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
let template = settings.prettyLogTemplate;
|
|
1181
|
-
const placeholderValues = {};
|
|
1182
|
-
if (template.includes("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}")) {
|
|
1183
|
-
template = template.replace("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}", "{{dateIsoStr}}");
|
|
1184
|
-
} else {
|
|
1185
|
-
if (settings.prettyLogTimeZone === "UTC") {
|
|
1186
|
-
placeholderValues["yyyy"] = meta.date?.getUTCFullYear() ?? "----";
|
|
1187
|
-
placeholderValues["mm"] = formatNumberAddZeros(meta.date?.getUTCMonth(), 2, 1);
|
|
1188
|
-
placeholderValues["dd"] = formatNumberAddZeros(meta.date?.getUTCDate(), 2);
|
|
1189
|
-
placeholderValues["hh"] = formatNumberAddZeros(meta.date?.getUTCHours(), 2);
|
|
1190
|
-
placeholderValues["MM"] = formatNumberAddZeros(meta.date?.getUTCMinutes(), 2);
|
|
1191
|
-
placeholderValues["ss"] = formatNumberAddZeros(meta.date?.getUTCSeconds(), 2);
|
|
1192
|
-
placeholderValues["ms"] = formatNumberAddZeros(meta.date?.getUTCMilliseconds(), 3);
|
|
1193
|
-
} else {
|
|
1194
|
-
placeholderValues["yyyy"] = meta.date?.getFullYear() ?? "----";
|
|
1195
|
-
placeholderValues["mm"] = formatNumberAddZeros(meta.date?.getMonth(), 2, 1);
|
|
1196
|
-
placeholderValues["dd"] = formatNumberAddZeros(meta.date?.getDate(), 2);
|
|
1197
|
-
placeholderValues["hh"] = formatNumberAddZeros(meta.date?.getHours(), 2);
|
|
1198
|
-
placeholderValues["MM"] = formatNumberAddZeros(meta.date?.getMinutes(), 2);
|
|
1199
|
-
placeholderValues["ss"] = formatNumberAddZeros(meta.date?.getSeconds(), 2);
|
|
1200
|
-
placeholderValues["ms"] = formatNumberAddZeros(meta.date?.getMilliseconds(), 3);
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
const dateInSettingsTimeZone = settings.prettyLogTimeZone === "UTC" ? meta.date : meta.date != null ? new Date(meta.date.getTime() - meta.date.getTimezoneOffset() * 60000) : undefined;
|
|
1204
|
-
placeholderValues["rawIsoStr"] = dateInSettingsTimeZone?.toISOString() ?? "";
|
|
1205
|
-
placeholderValues["dateIsoStr"] = dateInSettingsTimeZone?.toISOString().replace("T", " ").replace("Z", "") ?? "";
|
|
1206
|
-
placeholderValues["logLevelName"] = meta.logLevelName;
|
|
1207
|
-
placeholderValues["fileNameWithLine"] = meta.path?.fileNameWithLine ?? "";
|
|
1208
|
-
placeholderValues["filePathWithLine"] = meta.path?.filePathWithLine ?? "";
|
|
1209
|
-
placeholderValues["fullFilePath"] = meta.path?.fullFilePath ?? "";
|
|
1210
|
-
let parentNamesString = settings.parentNames?.join(settings.prettyErrorParentNamesSeparator);
|
|
1211
|
-
parentNamesString = parentNamesString != null && meta.name != null ? parentNamesString + settings.prettyErrorParentNamesSeparator : undefined;
|
|
1212
|
-
const combinedName = meta.name != null || parentNamesString != null ? `${parentNamesString ?? ""}${meta.name ?? ""}` : "";
|
|
1213
|
-
placeholderValues["name"] = combinedName;
|
|
1214
|
-
placeholderValues["nameWithDelimiterPrefix"] = combinedName.length > 0 ? settings.prettyErrorLoggerNameDelimiter + combinedName : "";
|
|
1215
|
-
placeholderValues["nameWithDelimiterSuffix"] = combinedName.length > 0 ? combinedName + settings.prettyErrorLoggerNameDelimiter : "";
|
|
1216
|
-
if (settings.overwrite?.addPlaceholders != null) {
|
|
1217
|
-
settings.overwrite.addPlaceholders(meta, placeholderValues);
|
|
1218
|
-
}
|
|
1219
|
-
return {
|
|
1220
|
-
text: formatTemplate(settings, template, placeholderValues),
|
|
1221
|
-
template,
|
|
1222
|
-
placeholders: placeholderValues
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/internal/stackTrace.js
|
|
1227
|
-
var DEFAULT_IGNORE_PATTERNS = [
|
|
1228
|
-
/(?:^|[\\/])node_modules[\\/].*tslog/i,
|
|
1229
|
-
/(?:^|[\\/])deps[\\/].*tslog/i,
|
|
1230
|
-
/tslog[\\/]+src[\\/]+internal[\\/]/i,
|
|
1231
|
-
/tslog[\\/]+src[\\/]BaseLogger/i,
|
|
1232
|
-
/tslog[\\/]+src[\\/]index/i
|
|
1233
|
-
];
|
|
1234
|
-
function splitStackLines(error) {
|
|
1235
|
-
const stack = typeof error?.stack === "string" ? error.stack : undefined;
|
|
1236
|
-
if (stack == null || stack.length === 0) {
|
|
1237
|
-
return [];
|
|
1238
|
-
}
|
|
1239
|
-
return stack.split(`
|
|
1240
|
-
`).map((line) => line.trimEnd());
|
|
1241
|
-
}
|
|
1242
|
-
function sanitizeStackLines(lines) {
|
|
1243
|
-
return lines.filter((line) => line.length > 0 && !/^\s*Error\b/.test(line));
|
|
1244
|
-
}
|
|
1245
|
-
function toStackFrames(lines, parseLine) {
|
|
1246
|
-
const frames = [];
|
|
1247
|
-
for (const line of lines) {
|
|
1248
|
-
const frame = parseLine(line);
|
|
1249
|
-
if (frame != null) {
|
|
1250
|
-
frames.push(frame);
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
return frames;
|
|
1254
|
-
}
|
|
1255
|
-
function findFirstExternalFrameIndex(frames, ignorePatterns = DEFAULT_IGNORE_PATTERNS) {
|
|
1256
|
-
for (let index = 0;index < frames.length; index += 1) {
|
|
1257
|
-
const frame = frames[index];
|
|
1258
|
-
const filePathCandidate = frame.filePath ?? "";
|
|
1259
|
-
const fullPathCandidate = frame.fullFilePath ?? "";
|
|
1260
|
-
if (!ignorePatterns.some((pattern) => pattern.test(filePathCandidate) || pattern.test(fullPathCandidate))) {
|
|
1261
|
-
return index;
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
return 0;
|
|
1265
|
-
}
|
|
1266
|
-
function getCleanStackLines(error) {
|
|
1267
|
-
return sanitizeStackLines(splitStackLines(error));
|
|
1268
|
-
}
|
|
1269
|
-
function buildStackTrace(error, parseLine) {
|
|
1270
|
-
return toStackFrames(getCleanStackLines(error), parseLine);
|
|
1271
|
-
}
|
|
1272
|
-
function clampIndex(index, maxExclusive) {
|
|
1273
|
-
if (index < 0) {
|
|
1274
|
-
return 0;
|
|
1275
|
-
}
|
|
1276
|
-
if (index >= maxExclusive) {
|
|
1277
|
-
return Math.max(0, maxExclusive - 1);
|
|
1278
|
-
}
|
|
1279
|
-
return index;
|
|
1280
|
-
}
|
|
1281
|
-
function getDefaultIgnorePatterns() {
|
|
1282
|
-
return [...DEFAULT_IGNORE_PATTERNS];
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/internal/errorUtils.js
|
|
1286
|
-
var DEFAULT_CAUSE_DEPTH = 5;
|
|
1287
|
-
function collectErrorCauses(error, options = {}) {
|
|
1288
|
-
const maxDepth = options.maxDepth ?? DEFAULT_CAUSE_DEPTH;
|
|
1289
|
-
const causes = [];
|
|
1290
|
-
const visited = new Set;
|
|
1291
|
-
let current = error;
|
|
1292
|
-
let depth = 0;
|
|
1293
|
-
while (current != null && depth < maxDepth) {
|
|
1294
|
-
const cause = current?.cause;
|
|
1295
|
-
if (cause == null || visited.has(cause)) {
|
|
1296
|
-
break;
|
|
1297
|
-
}
|
|
1298
|
-
visited.add(cause);
|
|
1299
|
-
causes.push(toError(cause));
|
|
1300
|
-
current = cause;
|
|
1301
|
-
depth += 1;
|
|
1302
|
-
}
|
|
1303
|
-
return causes;
|
|
1304
|
-
}
|
|
1305
|
-
function toError(value) {
|
|
1306
|
-
if (value instanceof Error) {
|
|
1307
|
-
return value;
|
|
1308
|
-
}
|
|
1309
|
-
const error = new Error(typeof value === "string" ? value : JSON.stringify(value));
|
|
1310
|
-
if (typeof value === "object" && value != null) {
|
|
1311
|
-
Object.assign(error, value);
|
|
1312
|
-
}
|
|
1313
|
-
return error;
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/internal/jsonStringifyRecursive.js
|
|
1317
|
-
function jsonStringifyRecursive(obj) {
|
|
1318
|
-
const cache = new Set;
|
|
1319
|
-
return JSON.stringify(obj, (key, value) => {
|
|
1320
|
-
if (typeof value === "object" && value !== null) {
|
|
1321
|
-
if (cache.has(value)) {
|
|
1322
|
-
return "[Circular]";
|
|
1323
|
-
}
|
|
1324
|
-
cache.add(value);
|
|
1325
|
-
}
|
|
1326
|
-
if (typeof value === "bigint") {
|
|
1327
|
-
return `${value}`;
|
|
1328
|
-
}
|
|
1329
|
-
if (typeof value === "undefined") {
|
|
1330
|
-
return "[undefined]";
|
|
1331
|
-
}
|
|
1332
|
-
return value;
|
|
1333
|
-
});
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/internal/util.inspect.polyfill.js
|
|
1337
|
-
function inspect(obj, opts) {
|
|
1338
|
-
const ctx = {
|
|
1339
|
-
seen: [],
|
|
1340
|
-
stylize: stylizeNoColor
|
|
1341
|
-
};
|
|
1342
|
-
if (opts != null) {
|
|
1343
|
-
_extend(ctx, opts);
|
|
1344
|
-
}
|
|
1345
|
-
if (isUndefined(ctx.showHidden))
|
|
1346
|
-
ctx.showHidden = false;
|
|
1347
|
-
if (isUndefined(ctx.depth))
|
|
1348
|
-
ctx.depth = 2;
|
|
1349
|
-
if (isUndefined(ctx.colors))
|
|
1350
|
-
ctx.colors = true;
|
|
1351
|
-
if (isUndefined(ctx.customInspect))
|
|
1352
|
-
ctx.customInspect = true;
|
|
1353
|
-
if (ctx.colors)
|
|
1354
|
-
ctx.stylize = stylizeWithColor;
|
|
1355
|
-
return formatValue(ctx, obj, ctx.depth);
|
|
1356
|
-
}
|
|
1357
|
-
inspect.colors = prettyLogStyles;
|
|
1358
|
-
inspect.styles = {
|
|
1359
|
-
special: "cyan",
|
|
1360
|
-
number: "yellow",
|
|
1361
|
-
boolean: "yellow",
|
|
1362
|
-
undefined: "grey",
|
|
1363
|
-
null: "bold",
|
|
1364
|
-
string: "green",
|
|
1365
|
-
date: "magenta",
|
|
1366
|
-
regexp: "red"
|
|
1367
|
-
};
|
|
1368
|
-
function isBoolean(arg) {
|
|
1369
|
-
return typeof arg === "boolean";
|
|
1370
|
-
}
|
|
1371
|
-
function isUndefined(arg) {
|
|
1372
|
-
return arg === undefined;
|
|
1373
|
-
}
|
|
1374
|
-
function stylizeNoColor(str) {
|
|
1375
|
-
return str;
|
|
1376
|
-
}
|
|
1377
|
-
function stylizeWithColor(str, styleType) {
|
|
1378
|
-
const style = inspect.styles[styleType];
|
|
1379
|
-
if (style != null && inspect?.colors?.[style]?.[0] != null && inspect?.colors?.[style]?.[1] != null) {
|
|
1380
|
-
return "\x1B[" + inspect.colors[style][0] + "m" + str + "\x1B[" + inspect.colors[style][1] + "m";
|
|
1381
|
-
} else {
|
|
1382
|
-
return str;
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
function isFunction(arg) {
|
|
1386
|
-
return typeof arg === "function";
|
|
1387
|
-
}
|
|
1388
|
-
function isString(arg) {
|
|
1389
|
-
return typeof arg === "string";
|
|
1390
|
-
}
|
|
1391
|
-
function isNumber(arg) {
|
|
1392
|
-
return typeof arg === "number";
|
|
1393
|
-
}
|
|
1394
|
-
function isNull(arg) {
|
|
1395
|
-
return arg === null;
|
|
1396
|
-
}
|
|
1397
|
-
function hasOwn(obj, prop) {
|
|
1398
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1399
|
-
}
|
|
1400
|
-
function isRegExp(re) {
|
|
1401
|
-
return isObject(re) && objectToString(re) === "[object RegExp]";
|
|
1402
|
-
}
|
|
1403
|
-
function isObject(arg) {
|
|
1404
|
-
return typeof arg === "object" && arg !== null;
|
|
1405
|
-
}
|
|
1406
|
-
function isError(e) {
|
|
1407
|
-
return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
|
|
1408
|
-
}
|
|
1409
|
-
function isDate(d) {
|
|
1410
|
-
return isObject(d) && objectToString(d) === "[object Date]";
|
|
1411
|
-
}
|
|
1412
|
-
function objectToString(o) {
|
|
1413
|
-
return Object.prototype.toString.call(o);
|
|
1414
|
-
}
|
|
1415
|
-
function arrayToHash(array) {
|
|
1416
|
-
const hash = {};
|
|
1417
|
-
array.forEach((val) => {
|
|
1418
|
-
hash[val] = true;
|
|
1419
|
-
});
|
|
1420
|
-
return hash;
|
|
1421
|
-
}
|
|
1422
|
-
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
1423
|
-
const output = [];
|
|
1424
|
-
for (let i = 0, l = value.length;i < l; ++i) {
|
|
1425
|
-
if (hasOwn(value, String(i))) {
|
|
1426
|
-
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
|
|
1427
|
-
} else {
|
|
1428
|
-
output.push("");
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
keys.forEach((key) => {
|
|
1432
|
-
if (!key.match(/^\d+$/)) {
|
|
1433
|
-
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
|
|
1434
|
-
}
|
|
1435
|
-
});
|
|
1436
|
-
return output;
|
|
1437
|
-
}
|
|
1438
|
-
function formatError(value) {
|
|
1439
|
-
return "[" + Error.prototype.toString.call(value) + "]";
|
|
1440
|
-
}
|
|
1441
|
-
function formatValue(ctx, value, recurseTimes = 0) {
|
|
1442
|
-
if (ctx.customInspect && value != null && isFunction(value) && value?.inspect !== inspect && !(value?.constructor && value?.constructor.prototype === value)) {
|
|
1443
|
-
if (typeof value.inspect !== "function" && value.toString != null) {
|
|
1444
|
-
return value.toString();
|
|
1445
|
-
}
|
|
1446
|
-
let ret = value?.inspect(recurseTimes, ctx);
|
|
1447
|
-
if (!isString(ret)) {
|
|
1448
|
-
ret = formatValue(ctx, ret, recurseTimes);
|
|
1449
|
-
}
|
|
1450
|
-
return ret;
|
|
1451
|
-
}
|
|
1452
|
-
const primitive = formatPrimitive(ctx, value);
|
|
1453
|
-
if (primitive) {
|
|
1454
|
-
return primitive;
|
|
1455
|
-
}
|
|
1456
|
-
let keys = Object.keys(value);
|
|
1457
|
-
const visibleKeys = arrayToHash(keys);
|
|
1458
|
-
try {
|
|
1459
|
-
if (ctx.showHidden && Object.getOwnPropertyNames) {
|
|
1460
|
-
keys = Object.getOwnPropertyNames(value);
|
|
1461
|
-
}
|
|
1462
|
-
} catch {}
|
|
1463
|
-
if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) {
|
|
1464
|
-
return formatError(value);
|
|
1465
|
-
}
|
|
1466
|
-
if (keys.length === 0) {
|
|
1467
|
-
if (isFunction(ctx.stylize)) {
|
|
1468
|
-
if (isFunction(value)) {
|
|
1469
|
-
const name = value.name ? ": " + value.name : "";
|
|
1470
|
-
return ctx.stylize("[Function" + name + "]", "special");
|
|
1471
|
-
}
|
|
1472
|
-
if (isRegExp(value)) {
|
|
1473
|
-
return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
|
|
1474
|
-
}
|
|
1475
|
-
if (isDate(value)) {
|
|
1476
|
-
return ctx.stylize(Date.prototype.toISOString.call(value), "date");
|
|
1477
|
-
}
|
|
1478
|
-
if (isError(value)) {
|
|
1479
|
-
return formatError(value);
|
|
1480
|
-
}
|
|
1481
|
-
} else {
|
|
1482
|
-
return value;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
let base = "";
|
|
1486
|
-
let array = false;
|
|
1487
|
-
let braces = [`{
|
|
1488
|
-
`, `
|
|
1489
|
-
}`];
|
|
1490
|
-
if (Array.isArray(value)) {
|
|
1491
|
-
array = true;
|
|
1492
|
-
braces = [`[
|
|
1493
|
-
`, `
|
|
1494
|
-
]`];
|
|
1495
|
-
}
|
|
1496
|
-
if (isFunction(value)) {
|
|
1497
|
-
const n = value.name ? ": " + value.name : "";
|
|
1498
|
-
base = " [Function" + n + "]";
|
|
1499
|
-
}
|
|
1500
|
-
if (isRegExp(value)) {
|
|
1501
|
-
base = " " + RegExp.prototype.toString.call(value);
|
|
1502
|
-
}
|
|
1503
|
-
if (isDate(value)) {
|
|
1504
|
-
base = " " + Date.prototype.toUTCString.call(value);
|
|
1505
|
-
}
|
|
1506
|
-
if (isError(value)) {
|
|
1507
|
-
base = " " + formatError(value);
|
|
1508
|
-
}
|
|
1509
|
-
if (keys.length === 0 && (!array || value.length == 0)) {
|
|
1510
|
-
return braces[0] + base + braces[1];
|
|
1511
|
-
}
|
|
1512
|
-
if (recurseTimes < 0) {
|
|
1513
|
-
if (isRegExp(value)) {
|
|
1514
|
-
return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
|
|
1515
|
-
} else {
|
|
1516
|
-
return ctx.stylize("[Object]", "special");
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
ctx.seen.push(value);
|
|
1520
|
-
let output;
|
|
1521
|
-
if (array) {
|
|
1522
|
-
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
1523
|
-
} else {
|
|
1524
|
-
output = keys.map((key) => {
|
|
1525
|
-
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
1526
|
-
});
|
|
1527
|
-
}
|
|
1528
|
-
ctx.seen.pop();
|
|
1529
|
-
return reduceToSingleString(output, base, braces);
|
|
1530
|
-
}
|
|
1531
|
-
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
1532
|
-
let name, str;
|
|
1533
|
-
let desc = { value: undefined };
|
|
1534
|
-
try {
|
|
1535
|
-
desc.value = value[key];
|
|
1536
|
-
} catch {}
|
|
1537
|
-
try {
|
|
1538
|
-
if (Object.getOwnPropertyDescriptor) {
|
|
1539
|
-
desc = Object.getOwnPropertyDescriptor(value, key) || desc;
|
|
1540
|
-
}
|
|
1541
|
-
} catch {}
|
|
1542
|
-
if (desc.get) {
|
|
1543
|
-
if (desc.set) {
|
|
1544
|
-
str = ctx.stylize("[Getter/Setter]", "special");
|
|
1545
|
-
} else {
|
|
1546
|
-
str = ctx.stylize("[Getter]", "special");
|
|
1547
|
-
}
|
|
1548
|
-
} else {
|
|
1549
|
-
if (desc.set) {
|
|
1550
|
-
str = ctx.stylize("[Setter]", "special");
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
if (!hasOwn(visibleKeys, key)) {
|
|
1554
|
-
name = "[" + key + "]";
|
|
1555
|
-
}
|
|
1556
|
-
if (!str) {
|
|
1557
|
-
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
1558
|
-
if (isNull(recurseTimes)) {
|
|
1559
|
-
str = formatValue(ctx, desc.value, undefined);
|
|
1560
|
-
} else {
|
|
1561
|
-
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
1562
|
-
}
|
|
1563
|
-
if (str.indexOf(`
|
|
1564
|
-
`) > -1) {
|
|
1565
|
-
if (array) {
|
|
1566
|
-
str = str.split(`
|
|
1567
|
-
`).map((line) => {
|
|
1568
|
-
return " " + line;
|
|
1569
|
-
}).join(`
|
|
1570
|
-
`).substr(2);
|
|
1571
|
-
} else {
|
|
1572
|
-
str = `
|
|
1573
|
-
` + str.split(`
|
|
1574
|
-
`).map((line) => {
|
|
1575
|
-
return " " + line;
|
|
1576
|
-
}).join(`
|
|
1577
|
-
`);
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
} else {
|
|
1581
|
-
str = ctx.stylize("[Circular]", "special");
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
if (isUndefined(name)) {
|
|
1585
|
-
if (array && key.match(/^\d+$/)) {
|
|
1586
|
-
return str;
|
|
1587
|
-
}
|
|
1588
|
-
name = JSON.stringify("" + key);
|
|
1589
|
-
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
1590
|
-
name = name.substr(1, name.length - 2);
|
|
1591
|
-
name = ctx.stylize(name, "name");
|
|
1592
|
-
} else {
|
|
1593
|
-
name = name.replace(/'/g, "\\'").replace(/\\"/g, "\\'").replace(/(^"|"$)/g, "'");
|
|
1594
|
-
name = ctx.stylize(name, "string");
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
return name + ": " + str;
|
|
1598
|
-
}
|
|
1599
|
-
function formatPrimitive(ctx, value) {
|
|
1600
|
-
if (isUndefined(value))
|
|
1601
|
-
return ctx.stylize("undefined", "undefined");
|
|
1602
|
-
if (isString(value)) {
|
|
1603
|
-
const simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\\'") + "'";
|
|
1604
|
-
return ctx.stylize(simple, "string");
|
|
1605
|
-
}
|
|
1606
|
-
if (isNumber(value))
|
|
1607
|
-
return ctx.stylize("" + value, "number");
|
|
1608
|
-
if (isBoolean(value))
|
|
1609
|
-
return ctx.stylize("" + value, "boolean");
|
|
1610
|
-
if (isNull(value))
|
|
1611
|
-
return ctx.stylize("null", "null");
|
|
1612
|
-
}
|
|
1613
|
-
function reduceToSingleString(output, base, braces) {
|
|
1614
|
-
return braces[0] + (base === "" ? "" : base + `
|
|
1615
|
-
`) + " " + output.join(`,
|
|
1616
|
-
`) + " " + braces[1];
|
|
1617
|
-
}
|
|
1618
|
-
function _extend(origin, add) {
|
|
1619
|
-
const typedOrigin = { ...origin };
|
|
1620
|
-
if (!add || !isObject(add))
|
|
1621
|
-
return origin;
|
|
1622
|
-
const clonedAdd = { ...add };
|
|
1623
|
-
const keys = Object.keys(add);
|
|
1624
|
-
let i = keys.length;
|
|
1625
|
-
while (i--) {
|
|
1626
|
-
typedOrigin[keys[i]] = clonedAdd[keys[i]];
|
|
1627
|
-
}
|
|
1628
|
-
return typedOrigin;
|
|
1629
|
-
}
|
|
1630
|
-
function formatWithOptions(inspectOptions, ...args) {
|
|
1631
|
-
const ctx = {
|
|
1632
|
-
seen: [],
|
|
1633
|
-
stylize: stylizeNoColor
|
|
1634
|
-
};
|
|
1635
|
-
if (inspectOptions != null) {
|
|
1636
|
-
_extend(ctx, inspectOptions);
|
|
1637
|
-
}
|
|
1638
|
-
const first = args[0];
|
|
1639
|
-
let a = 0;
|
|
1640
|
-
let str = "";
|
|
1641
|
-
let join = "";
|
|
1642
|
-
if (typeof first === "string") {
|
|
1643
|
-
if (args.length === 1) {
|
|
1644
|
-
return first;
|
|
1645
|
-
}
|
|
1646
|
-
let tempStr;
|
|
1647
|
-
let lastPos = 0;
|
|
1648
|
-
for (let i = 0;i < first.length - 1; i++) {
|
|
1649
|
-
if (first.charCodeAt(i) === 37) {
|
|
1650
|
-
const nextChar = first.charCodeAt(++i);
|
|
1651
|
-
if (a + 1 !== args.length) {
|
|
1652
|
-
switch (nextChar) {
|
|
1653
|
-
case 115: {
|
|
1654
|
-
const tempArg = args[++a];
|
|
1655
|
-
if (typeof tempArg === "number") {
|
|
1656
|
-
tempStr = formatPrimitive(ctx, tempArg);
|
|
1657
|
-
} else if (typeof tempArg === "bigint") {
|
|
1658
|
-
tempStr = formatPrimitive(ctx, tempArg);
|
|
1659
|
-
} else if (typeof tempArg !== "object" || tempArg === null) {
|
|
1660
|
-
tempStr = String(tempArg);
|
|
1661
|
-
} else {
|
|
1662
|
-
tempStr = inspect(tempArg, {
|
|
1663
|
-
...inspectOptions,
|
|
1664
|
-
compact: 3,
|
|
1665
|
-
colors: false,
|
|
1666
|
-
depth: 0
|
|
1667
|
-
});
|
|
1668
|
-
}
|
|
1669
|
-
break;
|
|
1670
|
-
}
|
|
1671
|
-
case 106:
|
|
1672
|
-
tempStr = jsonStringifyRecursive(args[++a]);
|
|
1673
|
-
break;
|
|
1674
|
-
case 100: {
|
|
1675
|
-
const tempNum = args[++a];
|
|
1676
|
-
if (typeof tempNum === "bigint") {
|
|
1677
|
-
tempStr = formatPrimitive(ctx, tempNum);
|
|
1678
|
-
} else if (typeof tempNum === "symbol") {
|
|
1679
|
-
tempStr = "NaN";
|
|
1680
|
-
} else {
|
|
1681
|
-
tempStr = formatPrimitive(ctx, tempNum);
|
|
1682
|
-
}
|
|
1683
|
-
break;
|
|
1684
|
-
}
|
|
1685
|
-
case 79:
|
|
1686
|
-
tempStr = inspect(args[++a], inspectOptions);
|
|
1687
|
-
break;
|
|
1688
|
-
case 111:
|
|
1689
|
-
tempStr = inspect(args[++a], {
|
|
1690
|
-
...inspectOptions,
|
|
1691
|
-
showHidden: true,
|
|
1692
|
-
showProxy: true,
|
|
1693
|
-
depth: 4
|
|
1694
|
-
});
|
|
1695
|
-
break;
|
|
1696
|
-
case 105: {
|
|
1697
|
-
const tempInteger = args[++a];
|
|
1698
|
-
if (typeof tempInteger === "bigint") {
|
|
1699
|
-
tempStr = formatPrimitive(ctx, tempInteger);
|
|
1700
|
-
} else if (typeof tempInteger === "symbol") {
|
|
1701
|
-
tempStr = "NaN";
|
|
1702
|
-
} else {
|
|
1703
|
-
tempStr = formatPrimitive(ctx, parseInt(tempStr));
|
|
1704
|
-
}
|
|
1705
|
-
break;
|
|
1706
|
-
}
|
|
1707
|
-
case 102: {
|
|
1708
|
-
const tempFloat = args[++a];
|
|
1709
|
-
if (typeof tempFloat === "symbol") {
|
|
1710
|
-
tempStr = "NaN";
|
|
1711
|
-
} else {
|
|
1712
|
-
tempStr = formatPrimitive(ctx, parseInt(tempFloat));
|
|
1713
|
-
}
|
|
1714
|
-
break;
|
|
1715
|
-
}
|
|
1716
|
-
case 99:
|
|
1717
|
-
a += 1;
|
|
1718
|
-
tempStr = "";
|
|
1719
|
-
break;
|
|
1720
|
-
case 37:
|
|
1721
|
-
str += first.slice(lastPos, i);
|
|
1722
|
-
lastPos = i + 1;
|
|
1723
|
-
continue;
|
|
1724
|
-
default:
|
|
1725
|
-
continue;
|
|
1726
|
-
}
|
|
1727
|
-
if (lastPos !== i - 1) {
|
|
1728
|
-
str += first.slice(lastPos, i - 1);
|
|
1729
|
-
}
|
|
1730
|
-
str += tempStr;
|
|
1731
|
-
lastPos = i + 1;
|
|
1732
|
-
} else if (nextChar === 37) {
|
|
1733
|
-
str += first.slice(lastPos, i);
|
|
1734
|
-
lastPos = i + 1;
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
if (lastPos !== 0) {
|
|
1739
|
-
a++;
|
|
1740
|
-
join = " ";
|
|
1741
|
-
if (lastPos < first.length) {
|
|
1742
|
-
str += first.slice(lastPos);
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
while (a < args.length) {
|
|
1747
|
-
const value = args[a];
|
|
1748
|
-
str += join;
|
|
1749
|
-
str += typeof value !== "string" ? inspect(value, inspectOptions) : value;
|
|
1750
|
-
join = " ";
|
|
1751
|
-
a++;
|
|
1752
|
-
}
|
|
1753
|
-
return str;
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/internal/environment.js
|
|
1757
|
-
function safeGetCwd() {
|
|
1758
|
-
try {
|
|
1759
|
-
const nodeProcess = globalThis?.process;
|
|
1760
|
-
if (typeof nodeProcess?.cwd === "function") {
|
|
1761
|
-
return nodeProcess.cwd();
|
|
1762
|
-
}
|
|
1763
|
-
} catch {}
|
|
1764
|
-
try {
|
|
1765
|
-
const deno = globalThis?.["Deno"];
|
|
1766
|
-
if (typeof deno?.cwd === "function") {
|
|
1767
|
-
return deno.cwd();
|
|
1768
|
-
}
|
|
1769
|
-
} catch {}
|
|
1770
|
-
return;
|
|
1771
|
-
}
|
|
1772
|
-
function isBrowserEnvironment() {
|
|
1773
|
-
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
1774
|
-
}
|
|
1775
|
-
function consoleSupportsCssStyling() {
|
|
1776
|
-
if (!isBrowserEnvironment()) {
|
|
1777
|
-
return false;
|
|
1778
|
-
}
|
|
1779
|
-
const navigatorObj = globalThis?.navigator;
|
|
1780
|
-
const userAgent = navigatorObj?.userAgent ?? "";
|
|
1781
|
-
if (/firefox/i.test(userAgent)) {
|
|
1782
|
-
return true;
|
|
1783
|
-
}
|
|
1784
|
-
const windowObj = globalThis;
|
|
1785
|
-
if (windowObj?.CSS?.supports?.("color", "#000")) {
|
|
1786
|
-
return true;
|
|
1787
|
-
}
|
|
1788
|
-
return /safari/i.test(userAgent) && !/chrome/i.test(userAgent);
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/BaseLogger.js
|
|
1792
|
-
function createLoggerEnvironment() {
|
|
1793
|
-
const runtimeInfo = detectRuntimeInfo();
|
|
1794
|
-
const meta = createRuntimeMeta(runtimeInfo);
|
|
1795
|
-
const usesBrowserStack = runtimeInfo.name === "browser" || runtimeInfo.name === "worker";
|
|
1796
|
-
const callerIgnorePatterns = usesBrowserStack ? [...getDefaultIgnorePatterns(), /node_modules[\\/].*tslog/i] : [...getDefaultIgnorePatterns(), /node:(?:internal|vm)/i, /\binternal[\\/]/i];
|
|
1797
|
-
let cachedCwd;
|
|
1798
|
-
const environment = {
|
|
1799
|
-
getMeta(logLevelId, logLevelName, stackDepthLevel, hideLogPositionForPerformance, name, parentNames) {
|
|
1800
|
-
return Object.assign({}, meta, {
|
|
1801
|
-
name,
|
|
1802
|
-
parentNames,
|
|
1803
|
-
date: new Date,
|
|
1804
|
-
logLevelId,
|
|
1805
|
-
logLevelName,
|
|
1806
|
-
path: !hideLogPositionForPerformance ? environment.getCallerStackFrame(stackDepthLevel) : undefined
|
|
1807
|
-
});
|
|
1808
|
-
},
|
|
1809
|
-
getCallerStackFrame(stackDepthLevel, error = new Error) {
|
|
1810
|
-
const frames = buildStackTrace(error, (line) => parseStackLine(line));
|
|
1811
|
-
if (frames.length === 0) {
|
|
1812
|
-
return {};
|
|
1813
|
-
}
|
|
1814
|
-
const autoIndex = findFirstExternalFrameIndex(frames, callerIgnorePatterns);
|
|
1815
|
-
const useManualIndex = Number.isFinite(stackDepthLevel) && stackDepthLevel >= 0;
|
|
1816
|
-
const resolvedIndex = useManualIndex ? clampIndex(stackDepthLevel, frames.length) : clampIndex(autoIndex, frames.length);
|
|
1817
|
-
return frames[resolvedIndex] ?? {};
|
|
1818
|
-
},
|
|
1819
|
-
getErrorTrace(error) {
|
|
1820
|
-
return buildStackTrace(error, (line) => parseStackLine(line));
|
|
1821
|
-
},
|
|
1822
|
-
isError(value) {
|
|
1823
|
-
return isNativeError(value);
|
|
1824
|
-
},
|
|
1825
|
-
isBuffer(value) {
|
|
1826
|
-
return typeof Buffer !== "undefined" && typeof Buffer.isBuffer === "function" ? Buffer.isBuffer(value) : false;
|
|
1827
|
-
},
|
|
1828
|
-
prettyFormatLogObj(maskedArgs, settings) {
|
|
1829
|
-
return maskedArgs.reduce((result, arg) => {
|
|
1830
|
-
if (environment.isError(arg)) {
|
|
1831
|
-
result.errors.push(environment.prettyFormatErrorObj(arg, settings));
|
|
1832
|
-
} else {
|
|
1833
|
-
result.args.push(arg);
|
|
1834
|
-
}
|
|
1835
|
-
return result;
|
|
1836
|
-
}, { args: [], errors: [] });
|
|
1837
|
-
},
|
|
1838
|
-
prettyFormatErrorObj(error, settings) {
|
|
1839
|
-
const stackLines = formatStackFrames(environment.getErrorTrace(error), settings);
|
|
1840
|
-
const causeSections = collectErrorCauses(error).map((cause, index) => {
|
|
1841
|
-
const header = `Caused by (${index + 1}): ${cause.name ?? "Error"}${cause.message ? `: ${cause.message}` : ""}`;
|
|
1842
|
-
const frames = formatStackFrames(buildStackTrace(cause, (line) => parseStackLine(line)), settings);
|
|
1843
|
-
return [header, ...frames].join(`
|
|
1844
|
-
`);
|
|
1845
|
-
});
|
|
1846
|
-
const placeholderValuesError = {
|
|
1847
|
-
errorName: ` ${error.name} `,
|
|
1848
|
-
errorMessage: formatErrorMessage(error),
|
|
1849
|
-
errorStack: [...stackLines, ...causeSections].join(`
|
|
1850
|
-
`)
|
|
1851
|
-
};
|
|
1852
|
-
return formatTemplate(settings, settings.prettyErrorTemplate, placeholderValuesError);
|
|
1853
|
-
},
|
|
1854
|
-
transportFormatted(logMetaMarkup, logArgs, logErrors, logMeta, settings) {
|
|
1855
|
-
const prettyLogs = settings.stylePrettyLogs !== false;
|
|
1856
|
-
const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? `
|
|
1857
|
-
` : "") + logErrors.join(`
|
|
1858
|
-
`);
|
|
1859
|
-
const sanitizedMetaMarkup = stripAnsi(logMetaMarkup);
|
|
1860
|
-
const metaMarkupForText = prettyLogs ? logMetaMarkup : sanitizedMetaMarkup;
|
|
1861
|
-
if (shouldUseCss(prettyLogs)) {
|
|
1862
|
-
settings.prettyInspectOptions.colors = false;
|
|
1863
|
-
const formattedArgs2 = formatWithOptionsSafe(settings.prettyInspectOptions, logArgs);
|
|
1864
|
-
const cssMeta = logMeta != null ? buildCssMetaOutput(settings, logMeta) : { text: sanitizedMetaMarkup, styles: [] };
|
|
1865
|
-
const hasCssMeta = cssMeta.text.length > 0 && cssMeta.styles.length > 0;
|
|
1866
|
-
const metaOutput = hasCssMeta ? cssMeta.text : sanitizedMetaMarkup;
|
|
1867
|
-
const output = metaOutput + formattedArgs2 + logErrorsStr;
|
|
1868
|
-
if (hasCssMeta) {
|
|
1869
|
-
console.log(output, ...cssMeta.styles);
|
|
1870
|
-
} else {
|
|
1871
|
-
console.log(output);
|
|
1872
|
-
}
|
|
1873
|
-
return;
|
|
1874
|
-
}
|
|
1875
|
-
settings.prettyInspectOptions.colors = prettyLogs;
|
|
1876
|
-
const formattedArgs = formatWithOptionsSafe(settings.prettyInspectOptions, logArgs);
|
|
1877
|
-
console.log(metaMarkupForText + formattedArgs + logErrorsStr);
|
|
1878
|
-
},
|
|
1879
|
-
transportJSON(json) {
|
|
1880
|
-
console.log(jsonStringifyRecursive(json));
|
|
1881
|
-
}
|
|
1882
|
-
};
|
|
1883
|
-
if (getNodeEnv() === "test") {
|
|
1884
|
-
environment.__resetWorkingDirectoryCacheForTests = () => {
|
|
1885
|
-
cachedCwd = undefined;
|
|
1886
|
-
};
|
|
1887
|
-
}
|
|
1888
|
-
return environment;
|
|
1889
|
-
function parseStackLine(line) {
|
|
1890
|
-
return usesBrowserStack ? parseBrowserStackLine(line) : parseServerStackLine(line);
|
|
1891
|
-
}
|
|
1892
|
-
function parseServerStackLine(rawLine) {
|
|
1893
|
-
if (typeof rawLine !== "string" || rawLine.length === 0) {
|
|
1894
|
-
return;
|
|
1895
|
-
}
|
|
1896
|
-
const trimmedLine = rawLine.trim();
|
|
1897
|
-
if (!trimmedLine.includes(" at ") && !trimmedLine.startsWith("at ")) {
|
|
1898
|
-
return;
|
|
1899
|
-
}
|
|
1900
|
-
const line = trimmedLine.replace(/^at\s+/, "");
|
|
1901
|
-
let method;
|
|
1902
|
-
let location = line;
|
|
1903
|
-
const methodMatch = line.match(/^(.*?)\s+\((.*)\)$/);
|
|
1904
|
-
if (methodMatch) {
|
|
1905
|
-
method = methodMatch[1];
|
|
1906
|
-
location = methodMatch[2];
|
|
1907
|
-
}
|
|
1908
|
-
const sanitizedLocation = location.replace(/^\(/, "").replace(/\)$/, "");
|
|
1909
|
-
const withoutQuery = sanitizedLocation.replace(/\?.*$/, "");
|
|
1910
|
-
let fileLine;
|
|
1911
|
-
let fileColumn;
|
|
1912
|
-
let filePathCandidate = withoutQuery;
|
|
1913
|
-
const segments = withoutQuery.split(":");
|
|
1914
|
-
if (segments.length >= 3 && /^\d+$/.test(segments[segments.length - 1] ?? "")) {
|
|
1915
|
-
fileColumn = segments.pop();
|
|
1916
|
-
fileLine = segments.pop();
|
|
1917
|
-
filePathCandidate = segments.join(":");
|
|
1918
|
-
} else if (segments.length >= 2 && /^\d+$/.test(segments[segments.length - 1] ?? "")) {
|
|
1919
|
-
fileLine = segments.pop();
|
|
1920
|
-
filePathCandidate = segments.join(":");
|
|
1921
|
-
}
|
|
1922
|
-
let normalizedPath = filePathCandidate.replace(/^file:\/\//, "");
|
|
1923
|
-
const cwd = getWorkingDirectory();
|
|
1924
|
-
if (cwd != null && normalizedPath.startsWith(cwd)) {
|
|
1925
|
-
normalizedPath = normalizedPath.slice(cwd.length);
|
|
1926
|
-
normalizedPath = normalizedPath.replace(/^[\\/]/, "");
|
|
1927
|
-
}
|
|
1928
|
-
if (normalizedPath.length === 0) {
|
|
1929
|
-
normalizedPath = filePathCandidate;
|
|
1930
|
-
}
|
|
1931
|
-
const normalizedPathWithoutLine = normalizeFilePath(normalizedPath);
|
|
1932
|
-
const effectivePath = normalizedPathWithoutLine.length > 0 ? normalizedPathWithoutLine : normalizedPath;
|
|
1933
|
-
const pathSegments = effectivePath.split(/\\|\//);
|
|
1934
|
-
const fileName = pathSegments[pathSegments.length - 1];
|
|
1935
|
-
const fileNameWithLine = fileName && fileLine ? `${fileName}:${fileLine}` : undefined;
|
|
1936
|
-
const filePathWithLine = effectivePath && fileLine ? `${effectivePath}:${fileLine}` : undefined;
|
|
1937
|
-
return {
|
|
1938
|
-
fullFilePath: sanitizedLocation,
|
|
1939
|
-
fileName,
|
|
1940
|
-
fileNameWithLine,
|
|
1941
|
-
fileColumn,
|
|
1942
|
-
fileLine,
|
|
1943
|
-
filePath: effectivePath,
|
|
1944
|
-
filePathWithLine,
|
|
1945
|
-
method
|
|
1946
|
-
};
|
|
1947
|
-
}
|
|
1948
|
-
function parseBrowserStackLine(line) {
|
|
1949
|
-
const href = globalThis.location?.origin;
|
|
1950
|
-
if (line == null) {
|
|
1951
|
-
return;
|
|
1952
|
-
}
|
|
1953
|
-
const match = line.match(BROWSER_PATH_REGEX);
|
|
1954
|
-
if (!match) {
|
|
1955
|
-
return;
|
|
1956
|
-
}
|
|
1957
|
-
const filePath = match[1]?.replace(/\?.*$/, "");
|
|
1958
|
-
if (filePath == null) {
|
|
1959
|
-
return;
|
|
1960
|
-
}
|
|
1961
|
-
const pathParts = filePath.split("/");
|
|
1962
|
-
const fileLine = match[2];
|
|
1963
|
-
const fileColumn = match[3];
|
|
1964
|
-
const fileName = pathParts[pathParts.length - 1];
|
|
1965
|
-
return {
|
|
1966
|
-
fullFilePath: href ? `${href}${filePath}` : filePath,
|
|
1967
|
-
fileName,
|
|
1968
|
-
fileNameWithLine: fileName && fileLine ? `${fileName}:${fileLine}` : undefined,
|
|
1969
|
-
fileColumn,
|
|
1970
|
-
fileLine,
|
|
1971
|
-
filePath,
|
|
1972
|
-
filePathWithLine: fileLine ? `${filePath}:${fileLine}` : undefined,
|
|
1973
|
-
method: undefined
|
|
1974
|
-
};
|
|
1975
|
-
}
|
|
1976
|
-
function formatStackFrames(frames, settings) {
|
|
1977
|
-
return frames.map((stackFrame) => formatTemplate(settings, settings.prettyErrorStackTemplate, { ...stackFrame }, true));
|
|
1978
|
-
}
|
|
1979
|
-
function formatErrorMessage(error) {
|
|
1980
|
-
return Object.getOwnPropertyNames(error).filter((key) => key !== "stack" && key !== "cause").reduce((result, key) => {
|
|
1981
|
-
const value = error[key];
|
|
1982
|
-
if (typeof value === "function") {
|
|
1983
|
-
return result;
|
|
1984
|
-
}
|
|
1985
|
-
result.push(String(value));
|
|
1986
|
-
return result;
|
|
1987
|
-
}, []).join(", ");
|
|
1988
|
-
}
|
|
1989
|
-
function shouldUseCss(prettyLogs) {
|
|
1990
|
-
return prettyLogs && (runtimeInfo.name === "browser" || runtimeInfo.name === "worker") && consoleSupportsCssStyling();
|
|
1991
|
-
}
|
|
1992
|
-
function stripAnsi(value) {
|
|
1993
|
-
return value.replace(ANSI_REGEX, "");
|
|
1994
|
-
}
|
|
1995
|
-
function buildCssMetaOutput(settings, metaValue) {
|
|
1996
|
-
if (metaValue == null) {
|
|
1997
|
-
return { text: "", styles: [] };
|
|
1998
|
-
}
|
|
1999
|
-
const { template, placeholders } = buildPrettyMeta(settings, metaValue);
|
|
2000
|
-
const parts = [];
|
|
2001
|
-
const styles = [];
|
|
2002
|
-
let lastIndex = 0;
|
|
2003
|
-
const placeholderRegex = /{{(.+?)}}/g;
|
|
2004
|
-
let match;
|
|
2005
|
-
while ((match = placeholderRegex.exec(template)) != null) {
|
|
2006
|
-
if (match.index > lastIndex) {
|
|
2007
|
-
parts.push(template.slice(lastIndex, match.index));
|
|
2008
|
-
}
|
|
2009
|
-
const key = match[1];
|
|
2010
|
-
const rawValue = placeholders[key] != null ? String(placeholders[key]) : "";
|
|
2011
|
-
const tokens = collectStyleTokens(settings.prettyLogStyles?.[key], rawValue);
|
|
2012
|
-
const css = tokensToCss(tokens);
|
|
2013
|
-
if (css.length > 0) {
|
|
2014
|
-
parts.push(`%c${rawValue}%c`);
|
|
2015
|
-
styles.push(css, "");
|
|
2016
|
-
} else {
|
|
2017
|
-
parts.push(rawValue);
|
|
2018
|
-
}
|
|
2019
|
-
lastIndex = placeholderRegex.lastIndex;
|
|
2020
|
-
}
|
|
2021
|
-
if (lastIndex < template.length) {
|
|
2022
|
-
parts.push(template.slice(lastIndex));
|
|
2023
|
-
}
|
|
2024
|
-
return {
|
|
2025
|
-
text: parts.join(""),
|
|
2026
|
-
styles
|
|
2027
|
-
};
|
|
2028
|
-
}
|
|
2029
|
-
function collectStyleTokens(style, value) {
|
|
2030
|
-
if (style == null) {
|
|
2031
|
-
return [];
|
|
2032
|
-
}
|
|
2033
|
-
if (typeof style === "string") {
|
|
2034
|
-
return [style];
|
|
2035
|
-
}
|
|
2036
|
-
if (Array.isArray(style)) {
|
|
2037
|
-
return style.flatMap((token) => collectStyleTokens(token, value));
|
|
2038
|
-
}
|
|
2039
|
-
if (typeof style === "object") {
|
|
2040
|
-
const normalizedValue = value.trim();
|
|
2041
|
-
const nextStyle = style[normalizedValue] ?? style["*"];
|
|
2042
|
-
if (nextStyle == null) {
|
|
2043
|
-
return [];
|
|
2044
|
-
}
|
|
2045
|
-
return collectStyleTokens(nextStyle, value);
|
|
2046
|
-
}
|
|
2047
|
-
return [];
|
|
2048
|
-
}
|
|
2049
|
-
function tokensToCss(tokens) {
|
|
2050
|
-
const seen = new Set;
|
|
2051
|
-
const cssParts = [];
|
|
2052
|
-
for (const token of tokens) {
|
|
2053
|
-
const css = styleTokenToCss(token);
|
|
2054
|
-
if (css != null && css.length > 0 && !seen.has(css)) {
|
|
2055
|
-
seen.add(css);
|
|
2056
|
-
cssParts.push(css);
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
return cssParts.join("; ");
|
|
2060
|
-
}
|
|
2061
|
-
function styleTokenToCss(token) {
|
|
2062
|
-
const color = COLOR_TOKENS[token];
|
|
2063
|
-
if (color != null) {
|
|
2064
|
-
return `color: ${color}`;
|
|
2065
|
-
}
|
|
2066
|
-
const background = BACKGROUND_TOKENS[token];
|
|
2067
|
-
if (background != null) {
|
|
2068
|
-
return `background-color: ${background}`;
|
|
2069
|
-
}
|
|
2070
|
-
switch (token) {
|
|
2071
|
-
case "bold":
|
|
2072
|
-
return "font-weight: bold";
|
|
2073
|
-
case "dim":
|
|
2074
|
-
return "opacity: 0.75";
|
|
2075
|
-
case "italic":
|
|
2076
|
-
return "font-style: italic";
|
|
2077
|
-
case "underline":
|
|
2078
|
-
return "text-decoration: underline";
|
|
2079
|
-
case "overline":
|
|
2080
|
-
return "text-decoration: overline";
|
|
2081
|
-
case "inverse":
|
|
2082
|
-
return "filter: invert(1)";
|
|
2083
|
-
case "hidden":
|
|
2084
|
-
return "visibility: hidden";
|
|
2085
|
-
case "strikethrough":
|
|
2086
|
-
return "text-decoration: line-through";
|
|
2087
|
-
default:
|
|
2088
|
-
return;
|
|
2089
|
-
}
|
|
2090
|
-
}
|
|
2091
|
-
function getWorkingDirectory() {
|
|
2092
|
-
if (cachedCwd === undefined) {
|
|
2093
|
-
cachedCwd = safeGetCwd() ?? null;
|
|
2094
|
-
}
|
|
2095
|
-
return cachedCwd ?? undefined;
|
|
2096
|
-
}
|
|
2097
|
-
function shouldCaptureHostname() {
|
|
2098
|
-
return runtimeInfo.name === "node" || runtimeInfo.name === "deno" || runtimeInfo.name === "bun";
|
|
2099
|
-
}
|
|
2100
|
-
function shouldCaptureRuntimeVersion() {
|
|
2101
|
-
return runtimeInfo.name === "node" || runtimeInfo.name === "deno" || runtimeInfo.name === "bun";
|
|
2102
|
-
}
|
|
2103
|
-
function createRuntimeMeta(info) {
|
|
2104
|
-
if (info.name === "browser" || info.name === "worker") {
|
|
2105
|
-
return {
|
|
2106
|
-
runtime: info.name,
|
|
2107
|
-
browser: info.userAgent
|
|
2108
|
-
};
|
|
2109
|
-
}
|
|
2110
|
-
const metaStatic = {
|
|
2111
|
-
runtime: info.name
|
|
2112
|
-
};
|
|
2113
|
-
if (shouldCaptureRuntimeVersion()) {
|
|
2114
|
-
metaStatic.runtimeVersion = info.version ?? "unknown";
|
|
2115
|
-
}
|
|
2116
|
-
if (shouldCaptureHostname()) {
|
|
2117
|
-
metaStatic.hostname = info.hostname ?? "unknown";
|
|
2118
|
-
}
|
|
2119
|
-
return metaStatic;
|
|
2120
|
-
}
|
|
2121
|
-
function formatWithOptionsSafe(options, args) {
|
|
2122
|
-
try {
|
|
2123
|
-
return formatWithOptions(options, ...args);
|
|
2124
|
-
} catch {
|
|
2125
|
-
return args.map(stringifyFallback).join(" ");
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
function stringifyFallback(value) {
|
|
2129
|
-
if (typeof value === "string") {
|
|
2130
|
-
return value;
|
|
2131
|
-
}
|
|
2132
|
-
try {
|
|
2133
|
-
return JSON.stringify(value);
|
|
2134
|
-
} catch {
|
|
2135
|
-
return String(value);
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
function normalizeFilePath(value) {
|
|
2139
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
2140
|
-
return value;
|
|
2141
|
-
}
|
|
2142
|
-
const replaced = value.replace(/\\+/g, "\\").replace(/\\/g, "/");
|
|
2143
|
-
const hasRootDoubleSlash = replaced.startsWith("//");
|
|
2144
|
-
const hasLeadingSlash = replaced.startsWith("/") && !hasRootDoubleSlash;
|
|
2145
|
-
const driveMatch = replaced.match(/^[A-Za-z]:/);
|
|
2146
|
-
const drivePrefix = driveMatch ? driveMatch[0] : "";
|
|
2147
|
-
const withoutDrive = drivePrefix ? replaced.slice(drivePrefix.length) : replaced;
|
|
2148
|
-
const segments = withoutDrive.split("/");
|
|
2149
|
-
const normalizedSegments = [];
|
|
2150
|
-
for (const segment of segments) {
|
|
2151
|
-
if (segment === "" || segment === ".") {
|
|
2152
|
-
continue;
|
|
2153
|
-
}
|
|
2154
|
-
if (segment === "..") {
|
|
2155
|
-
if (normalizedSegments.length > 0) {
|
|
2156
|
-
normalizedSegments.pop();
|
|
2157
|
-
}
|
|
2158
|
-
continue;
|
|
2159
|
-
}
|
|
2160
|
-
normalizedSegments.push(segment);
|
|
2161
|
-
}
|
|
2162
|
-
let normalized = normalizedSegments.join("/");
|
|
2163
|
-
if (hasRootDoubleSlash) {
|
|
2164
|
-
normalized = `//${normalized}`;
|
|
2165
|
-
} else if (hasLeadingSlash) {
|
|
2166
|
-
normalized = `/${normalized}`;
|
|
2167
|
-
} else if (drivePrefix !== "") {
|
|
2168
|
-
normalized = `${drivePrefix}${normalized.length > 0 ? `/${normalized}` : ""}`;
|
|
2169
|
-
}
|
|
2170
|
-
if (normalized.length === 0) {
|
|
2171
|
-
return value;
|
|
2172
|
-
}
|
|
2173
|
-
return normalized;
|
|
2174
|
-
}
|
|
2175
|
-
function detectRuntimeInfo() {
|
|
2176
|
-
if (isBrowserEnvironment()) {
|
|
2177
|
-
const navigatorObj = globalThis.navigator;
|
|
2178
|
-
return {
|
|
2179
|
-
name: "browser",
|
|
2180
|
-
userAgent: navigatorObj?.userAgent
|
|
2181
|
-
};
|
|
2182
|
-
}
|
|
2183
|
-
const globalScope = globalThis;
|
|
2184
|
-
if (typeof globalScope.importScripts === "function") {
|
|
2185
|
-
return {
|
|
2186
|
-
name: "worker",
|
|
2187
|
-
userAgent: globalScope.navigator?.userAgent
|
|
2188
|
-
};
|
|
2189
|
-
}
|
|
2190
|
-
const globalAny = globalThis;
|
|
2191
|
-
if (globalAny.Bun != null) {
|
|
2192
|
-
const bunVersion = globalAny.Bun.version;
|
|
2193
|
-
return {
|
|
2194
|
-
name: "bun",
|
|
2195
|
-
version: bunVersion != null ? `bun/${bunVersion}` : undefined,
|
|
2196
|
-
hostname: getEnvironmentHostname(globalAny.process, globalAny.Deno, globalAny.Bun, globalAny.location)
|
|
2197
|
-
};
|
|
2198
|
-
}
|
|
2199
|
-
if (globalAny.Deno != null) {
|
|
2200
|
-
const denoHostname = resolveDenoHostname(globalAny.Deno);
|
|
2201
|
-
const denoVersion = globalAny.Deno?.version?.deno;
|
|
2202
|
-
return {
|
|
2203
|
-
name: "deno",
|
|
2204
|
-
version: denoVersion != null ? `deno/${denoVersion}` : undefined,
|
|
2205
|
-
hostname: denoHostname ?? getEnvironmentHostname(globalAny.process, globalAny.Deno, globalAny.Bun, globalAny.location)
|
|
2206
|
-
};
|
|
2207
|
-
}
|
|
2208
|
-
if (globalAny.process?.versions?.node != null || globalAny.process?.version != null) {
|
|
2209
|
-
return {
|
|
2210
|
-
name: "node",
|
|
2211
|
-
version: globalAny.process?.versions?.node ?? globalAny.process?.version,
|
|
2212
|
-
hostname: getEnvironmentHostname(globalAny.process, globalAny.Deno, globalAny.Bun, globalAny.location)
|
|
2213
|
-
};
|
|
2214
|
-
}
|
|
2215
|
-
if (globalAny.process != null) {
|
|
2216
|
-
return {
|
|
2217
|
-
name: "node",
|
|
2218
|
-
version: "unknown",
|
|
2219
|
-
hostname: getEnvironmentHostname(globalAny.process, globalAny.Deno, globalAny.Bun, globalAny.location)
|
|
2220
|
-
};
|
|
2221
|
-
}
|
|
2222
|
-
return {
|
|
2223
|
-
name: "unknown"
|
|
2224
|
-
};
|
|
2225
|
-
}
|
|
2226
|
-
function getEnvironmentHostname(nodeProcess, deno, bun, location) {
|
|
2227
|
-
const processHostname = nodeProcess?.env?.HOSTNAME ?? nodeProcess?.env?.HOST ?? nodeProcess?.env?.COMPUTERNAME;
|
|
2228
|
-
if (processHostname != null && processHostname.length > 0) {
|
|
2229
|
-
return processHostname;
|
|
2230
|
-
}
|
|
2231
|
-
const bunHostname = bun?.env?.HOSTNAME ?? bun?.env?.HOST ?? bun?.env?.COMPUTERNAME;
|
|
2232
|
-
if (bunHostname != null && bunHostname.length > 0) {
|
|
2233
|
-
return bunHostname;
|
|
2234
|
-
}
|
|
2235
|
-
try {
|
|
2236
|
-
const denoEnvGet = deno?.env?.get;
|
|
2237
|
-
if (typeof denoEnvGet === "function") {
|
|
2238
|
-
const value = denoEnvGet("HOSTNAME");
|
|
2239
|
-
if (value != null && value.length > 0) {
|
|
2240
|
-
return value;
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
} catch {}
|
|
2244
|
-
if (location?.hostname != null && location.hostname.length > 0) {
|
|
2245
|
-
return location.hostname;
|
|
2246
|
-
}
|
|
2247
|
-
return;
|
|
2248
|
-
}
|
|
2249
|
-
function resolveDenoHostname(deno) {
|
|
2250
|
-
try {
|
|
2251
|
-
if (typeof deno?.hostname === "function") {
|
|
2252
|
-
const value = deno.hostname();
|
|
2253
|
-
if (value != null && value.length > 0) {
|
|
2254
|
-
return value;
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
} catch {}
|
|
2258
|
-
const locationHostname = globalThis.location?.hostname;
|
|
2259
|
-
if (locationHostname != null && locationHostname.length > 0) {
|
|
2260
|
-
return locationHostname;
|
|
2261
|
-
}
|
|
2262
|
-
return;
|
|
2263
|
-
}
|
|
2264
|
-
function getNodeEnv() {
|
|
2265
|
-
const globalProcess = globalThis?.process;
|
|
2266
|
-
return globalProcess?.env?.NODE_ENV;
|
|
2267
|
-
}
|
|
2268
|
-
function isNativeError(value) {
|
|
2269
|
-
if (value instanceof Error) {
|
|
2270
|
-
return true;
|
|
2271
|
-
}
|
|
2272
|
-
if (value != null && typeof value === "object") {
|
|
2273
|
-
const objectTag = Object.prototype.toString.call(value);
|
|
2274
|
-
if (/\[object .*Error\]/.test(objectTag)) {
|
|
2275
|
-
return true;
|
|
2276
|
-
}
|
|
2277
|
-
const name = value.name;
|
|
2278
|
-
if (typeof name === "string" && name.endsWith("Error")) {
|
|
2279
|
-
return true;
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2282
|
-
return false;
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
var ANSI_REGEX = /\u001b\[[0-9;]*m/g;
|
|
2286
|
-
var COLOR_TOKENS = {
|
|
2287
|
-
black: "#000000",
|
|
2288
|
-
red: "#ef5350",
|
|
2289
|
-
green: "#66bb6a",
|
|
2290
|
-
yellow: "#fdd835",
|
|
2291
|
-
blue: "#42a5f5",
|
|
2292
|
-
magenta: "#ab47bc",
|
|
2293
|
-
cyan: "#26c6da",
|
|
2294
|
-
white: "#fafafa",
|
|
2295
|
-
blackBright: "#424242",
|
|
2296
|
-
redBright: "#ff7043",
|
|
2297
|
-
greenBright: "#81c784",
|
|
2298
|
-
yellowBright: "#ffe082",
|
|
2299
|
-
blueBright: "#64b5f6",
|
|
2300
|
-
magentaBright: "#ce93d8",
|
|
2301
|
-
cyanBright: "#4dd0e1",
|
|
2302
|
-
whiteBright: "#ffffff"
|
|
2303
|
-
};
|
|
2304
|
-
var BACKGROUND_TOKENS = {
|
|
2305
|
-
bgBlack: "#000000",
|
|
2306
|
-
bgRed: "#ef5350",
|
|
2307
|
-
bgGreen: "#66bb6a",
|
|
2308
|
-
bgYellow: "#fdd835",
|
|
2309
|
-
bgBlue: "#42a5f5",
|
|
2310
|
-
bgMagenta: "#ab47bc",
|
|
2311
|
-
bgCyan: "#26c6da",
|
|
2312
|
-
bgWhite: "#fafafa",
|
|
2313
|
-
bgBlackBright: "#424242",
|
|
2314
|
-
bgRedBright: "#ff7043",
|
|
2315
|
-
bgGreenBright: "#81c784",
|
|
2316
|
-
bgYellowBright: "#ffe082",
|
|
2317
|
-
bgBlueBright: "#64b5f6",
|
|
2318
|
-
bgMagentaBright: "#ce93d8",
|
|
2319
|
-
bgCyanBright: "#4dd0e1",
|
|
2320
|
-
bgWhiteBright: "#ffffff"
|
|
2321
|
-
};
|
|
2322
|
-
var BROWSER_PATH_REGEX = /(?:(?:file|https?|global code|[^@]+)@)?(?:file:)?((?:\/[^:/]+){2,})(?::(\d+))?(?::(\d+))?/;
|
|
2323
|
-
var runtime = createLoggerEnvironment();
|
|
2324
|
-
class BaseLogger {
|
|
2325
|
-
constructor(settings, logObj, stackDepthLevel = Number.NaN) {
|
|
2326
|
-
this.logObj = logObj;
|
|
2327
|
-
this.stackDepthLevel = stackDepthLevel;
|
|
2328
|
-
this.runtime = runtime;
|
|
2329
|
-
this.maxErrorCauseDepth = 5;
|
|
2330
|
-
this.settings = {
|
|
2331
|
-
type: settings?.type ?? "pretty",
|
|
2332
|
-
name: settings?.name,
|
|
2333
|
-
parentNames: settings?.parentNames,
|
|
2334
|
-
minLevel: settings?.minLevel ?? 0,
|
|
2335
|
-
argumentsArrayName: settings?.argumentsArrayName,
|
|
2336
|
-
hideLogPositionForProduction: settings?.hideLogPositionForProduction ?? false,
|
|
2337
|
-
prettyLogTemplate: settings?.prettyLogTemplate ?? "{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t{{filePathWithLine}}{{nameWithDelimiterPrefix}}\t",
|
|
2338
|
-
prettyErrorTemplate: settings?.prettyErrorTemplate ?? `
|
|
2339
|
-
{{errorName}} {{errorMessage}}
|
|
2340
|
-
error stack:
|
|
2341
|
-
{{errorStack}}`,
|
|
2342
|
-
prettyErrorStackTemplate: settings?.prettyErrorStackTemplate ?? ` • {{fileName}} {{method}}
|
|
2343
|
-
{{filePathWithLine}}`,
|
|
2344
|
-
prettyErrorParentNamesSeparator: settings?.prettyErrorParentNamesSeparator ?? ":",
|
|
2345
|
-
prettyErrorLoggerNameDelimiter: settings?.prettyErrorLoggerNameDelimiter ?? "\t",
|
|
2346
|
-
stylePrettyLogs: settings?.stylePrettyLogs ?? true,
|
|
2347
|
-
prettyLogTimeZone: settings?.prettyLogTimeZone ?? "UTC",
|
|
2348
|
-
prettyLogStyles: settings?.prettyLogStyles ?? {
|
|
2349
|
-
logLevelName: {
|
|
2350
|
-
"*": ["bold", "black", "bgWhiteBright", "dim"],
|
|
2351
|
-
SILLY: ["bold", "white"],
|
|
2352
|
-
TRACE: ["bold", "whiteBright"],
|
|
2353
|
-
DEBUG: ["bold", "green"],
|
|
2354
|
-
INFO: ["bold", "blue"],
|
|
2355
|
-
WARN: ["bold", "yellow"],
|
|
2356
|
-
ERROR: ["bold", "red"],
|
|
2357
|
-
FATAL: ["bold", "redBright"]
|
|
2358
|
-
},
|
|
2359
|
-
dateIsoStr: "white",
|
|
2360
|
-
filePathWithLine: "white",
|
|
2361
|
-
name: ["white", "bold"],
|
|
2362
|
-
nameWithDelimiterPrefix: ["white", "bold"],
|
|
2363
|
-
nameWithDelimiterSuffix: ["white", "bold"],
|
|
2364
|
-
errorName: ["bold", "bgRedBright", "whiteBright"],
|
|
2365
|
-
fileName: ["yellow"],
|
|
2366
|
-
fileNameWithLine: "white"
|
|
2367
|
-
},
|
|
2368
|
-
prettyInspectOptions: settings?.prettyInspectOptions ?? {
|
|
2369
|
-
colors: true,
|
|
2370
|
-
compact: false,
|
|
2371
|
-
depth: Infinity
|
|
2372
|
-
},
|
|
2373
|
-
metaProperty: settings?.metaProperty ?? "_meta",
|
|
2374
|
-
maskPlaceholder: settings?.maskPlaceholder ?? "[***]",
|
|
2375
|
-
maskValuesOfKeys: settings?.maskValuesOfKeys ?? ["password"],
|
|
2376
|
-
maskValuesOfKeysCaseInsensitive: settings?.maskValuesOfKeysCaseInsensitive ?? false,
|
|
2377
|
-
maskValuesRegEx: settings?.maskValuesRegEx,
|
|
2378
|
-
prefix: [...settings?.prefix ?? []],
|
|
2379
|
-
attachedTransports: [...settings?.attachedTransports ?? []],
|
|
2380
|
-
overwrite: {
|
|
2381
|
-
mask: settings?.overwrite?.mask,
|
|
2382
|
-
toLogObj: settings?.overwrite?.toLogObj,
|
|
2383
|
-
addMeta: settings?.overwrite?.addMeta,
|
|
2384
|
-
addPlaceholders: settings?.overwrite?.addPlaceholders,
|
|
2385
|
-
formatMeta: settings?.overwrite?.formatMeta,
|
|
2386
|
-
formatLogObj: settings?.overwrite?.formatLogObj,
|
|
2387
|
-
transportFormatted: settings?.overwrite?.transportFormatted,
|
|
2388
|
-
transportJSON: settings?.overwrite?.transportJSON
|
|
2389
|
-
}
|
|
2390
|
-
};
|
|
2391
|
-
this.captureStackForMeta = this._shouldCaptureStack();
|
|
2392
|
-
}
|
|
2393
|
-
log(logLevelId, logLevelName, ...args) {
|
|
2394
|
-
if (logLevelId < this.settings.minLevel) {
|
|
2395
|
-
return;
|
|
2396
|
-
}
|
|
2397
|
-
const resolvedArgs = this._resolveLogArguments(args);
|
|
2398
|
-
const logArgs = [...this.settings.prefix, ...resolvedArgs];
|
|
2399
|
-
const maskedArgs = this.settings.overwrite?.mask != null ? this.settings.overwrite?.mask(logArgs) : this.settings.maskValuesOfKeys != null && this.settings.maskValuesOfKeys.length > 0 ? this._mask(logArgs) : logArgs;
|
|
2400
|
-
const thisLogObj = this.logObj != null ? this._recursiveCloneAndExecuteFunctions(this.logObj) : undefined;
|
|
2401
|
-
const logObj = this.settings.overwrite?.toLogObj != null ? this.settings.overwrite?.toLogObj(maskedArgs, thisLogObj) : this._toLogObj(maskedArgs, thisLogObj);
|
|
2402
|
-
const logObjWithMeta = this.settings.overwrite?.addMeta != null ? this.settings.overwrite?.addMeta(logObj, logLevelId, logLevelName) : this._addMetaToLogObj(logObj, logLevelId, logLevelName);
|
|
2403
|
-
const logMeta = logObjWithMeta?.[this.settings.metaProperty];
|
|
2404
|
-
let logMetaMarkup;
|
|
2405
|
-
let logArgsAndErrorsMarkup = undefined;
|
|
2406
|
-
if (this.settings.overwrite?.formatMeta != null) {
|
|
2407
|
-
logMetaMarkup = this.settings.overwrite?.formatMeta(logObjWithMeta?.[this.settings.metaProperty]);
|
|
2408
|
-
}
|
|
2409
|
-
if (this.settings.overwrite?.formatLogObj != null) {
|
|
2410
|
-
logArgsAndErrorsMarkup = this.settings.overwrite?.formatLogObj(maskedArgs, this.settings);
|
|
2411
|
-
}
|
|
2412
|
-
if (this.settings.type === "pretty") {
|
|
2413
|
-
logMetaMarkup = logMetaMarkup ?? this._prettyFormatLogObjMeta(logObjWithMeta?.[this.settings.metaProperty]);
|
|
2414
|
-
logArgsAndErrorsMarkup = logArgsAndErrorsMarkup ?? runtime.prettyFormatLogObj(maskedArgs, this.settings);
|
|
2415
|
-
}
|
|
2416
|
-
if (logMetaMarkup != null && logArgsAndErrorsMarkup != null) {
|
|
2417
|
-
if (this.settings.overwrite?.transportFormatted != null) {
|
|
2418
|
-
const transport = this.settings.overwrite.transportFormatted;
|
|
2419
|
-
const declaredParams = transport.length;
|
|
2420
|
-
if (declaredParams < 4) {
|
|
2421
|
-
transport(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors);
|
|
2422
|
-
} else if (declaredParams === 4) {
|
|
2423
|
-
transport(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, logMeta);
|
|
2424
|
-
} else {
|
|
2425
|
-
transport(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, logMeta, this.settings);
|
|
2426
|
-
}
|
|
2427
|
-
} else {
|
|
2428
|
-
runtime.transportFormatted(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, logMeta, this.settings);
|
|
2429
|
-
}
|
|
2430
|
-
} else {
|
|
2431
|
-
if (this.settings.overwrite?.transportJSON != null) {
|
|
2432
|
-
this.settings.overwrite.transportJSON(logObjWithMeta);
|
|
2433
|
-
} else if (this.settings.type !== "hidden") {
|
|
2434
|
-
runtime.transportJSON(logObjWithMeta);
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
if (this.settings.attachedTransports != null && this.settings.attachedTransports.length > 0) {
|
|
2438
|
-
this.settings.attachedTransports.forEach((transportLogger) => {
|
|
2439
|
-
transportLogger(logObjWithMeta);
|
|
2440
|
-
});
|
|
2441
|
-
}
|
|
2442
|
-
return logObjWithMeta;
|
|
2443
|
-
}
|
|
2444
|
-
attachTransport(transportLogger) {
|
|
2445
|
-
this.settings.attachedTransports.push(transportLogger);
|
|
2446
|
-
}
|
|
2447
|
-
getSubLogger(settings, logObj) {
|
|
2448
|
-
const subLoggerSettings = {
|
|
2449
|
-
...this.settings,
|
|
2450
|
-
...settings,
|
|
2451
|
-
parentNames: this.settings?.parentNames != null && this.settings?.name != null ? [...this.settings.parentNames, this.settings.name] : this.settings?.name != null ? [this.settings.name] : undefined,
|
|
2452
|
-
prefix: [...this.settings.prefix, ...settings?.prefix ?? []]
|
|
2453
|
-
};
|
|
2454
|
-
const subLogger = new this.constructor(subLoggerSettings, logObj ?? this.logObj, this.stackDepthLevel);
|
|
2455
|
-
return subLogger;
|
|
2456
|
-
}
|
|
2457
|
-
_mask(args) {
|
|
2458
|
-
const maskKeys = this._getMaskKeys();
|
|
2459
|
-
return args?.map((arg) => {
|
|
2460
|
-
return this._recursiveCloneAndMaskValuesOfKeys(arg, maskKeys);
|
|
2461
|
-
});
|
|
2462
|
-
}
|
|
2463
|
-
_getMaskKeys() {
|
|
2464
|
-
const maskKeys = this.settings.maskValuesOfKeys ?? [];
|
|
2465
|
-
const signature = maskKeys.map(String).join("|");
|
|
2466
|
-
if (this.settings.maskValuesOfKeysCaseInsensitive === true) {
|
|
2467
|
-
if (this.maskKeysCache?.source === maskKeys && this.maskKeysCache.caseInsensitive === true && this.maskKeysCache.signature === signature) {
|
|
2468
|
-
return this.maskKeysCache.normalized;
|
|
2469
|
-
}
|
|
2470
|
-
const normalized = maskKeys.map((key) => typeof key === "string" ? key.toLowerCase() : String(key).toLowerCase());
|
|
2471
|
-
this.maskKeysCache = {
|
|
2472
|
-
source: maskKeys,
|
|
2473
|
-
caseInsensitive: true,
|
|
2474
|
-
normalized,
|
|
2475
|
-
signature
|
|
2476
|
-
};
|
|
2477
|
-
return normalized;
|
|
2478
|
-
}
|
|
2479
|
-
this.maskKeysCache = {
|
|
2480
|
-
source: maskKeys,
|
|
2481
|
-
caseInsensitive: false,
|
|
2482
|
-
normalized: maskKeys,
|
|
2483
|
-
signature
|
|
2484
|
-
};
|
|
2485
|
-
return maskKeys;
|
|
2486
|
-
}
|
|
2487
|
-
_resolveLogArguments(args) {
|
|
2488
|
-
if (args.length === 1 && typeof args[0] === "function") {
|
|
2489
|
-
const candidate = args[0];
|
|
2490
|
-
if (candidate.length === 0) {
|
|
2491
|
-
const result = candidate();
|
|
2492
|
-
return Array.isArray(result) ? result : [result];
|
|
2493
|
-
}
|
|
2494
|
-
}
|
|
2495
|
-
return args;
|
|
2496
|
-
}
|
|
2497
|
-
_recursiveCloneAndMaskValuesOfKeys(source, keys, seen = []) {
|
|
2498
|
-
if (seen.includes(source)) {
|
|
2499
|
-
return { ...source };
|
|
2500
|
-
}
|
|
2501
|
-
if (typeof source === "object" && source !== null) {
|
|
2502
|
-
seen.push(source);
|
|
2503
|
-
}
|
|
2504
|
-
if (runtime.isError(source) || runtime.isBuffer(source)) {
|
|
2505
|
-
return source;
|
|
2506
|
-
} else if (source instanceof Map) {
|
|
2507
|
-
return new Map(source);
|
|
2508
|
-
} else if (source instanceof Set) {
|
|
2509
|
-
return new Set(source);
|
|
2510
|
-
} else if (Array.isArray(source)) {
|
|
2511
|
-
return source.map((item) => this._recursiveCloneAndMaskValuesOfKeys(item, keys, seen));
|
|
2512
|
-
} else if (source instanceof Date) {
|
|
2513
|
-
return new Date(source.getTime());
|
|
2514
|
-
} else if (source instanceof URL) {
|
|
2515
|
-
return urlToObject(source);
|
|
2516
|
-
} else if (source !== null && typeof source === "object") {
|
|
2517
|
-
const baseObject = runtime.isError(source) ? this._cloneError(source) : Object.create(Object.getPrototypeOf(source));
|
|
2518
|
-
return Object.getOwnPropertyNames(source).reduce((o, prop) => {
|
|
2519
|
-
const lookupKey = this.settings?.maskValuesOfKeysCaseInsensitive !== true ? prop : typeof prop === "string" ? prop.toLowerCase() : String(prop).toLowerCase();
|
|
2520
|
-
o[prop] = keys.includes(lookupKey) ? this.settings.maskPlaceholder : (() => {
|
|
2521
|
-
try {
|
|
2522
|
-
return this._recursiveCloneAndMaskValuesOfKeys(source[prop], keys, seen);
|
|
2523
|
-
} catch {
|
|
2524
|
-
return null;
|
|
2525
|
-
}
|
|
2526
|
-
})();
|
|
2527
|
-
return o;
|
|
2528
|
-
}, baseObject);
|
|
2529
|
-
} else {
|
|
2530
|
-
if (typeof source === "string") {
|
|
2531
|
-
let modifiedSource = source;
|
|
2532
|
-
for (const regEx of this.settings?.maskValuesRegEx || []) {
|
|
2533
|
-
modifiedSource = modifiedSource.replace(regEx, this.settings?.maskPlaceholder || "");
|
|
2534
|
-
}
|
|
2535
|
-
return modifiedSource;
|
|
2536
|
-
}
|
|
2537
|
-
return source;
|
|
2538
|
-
}
|
|
2539
|
-
}
|
|
2540
|
-
_recursiveCloneAndExecuteFunctions(source, seen = []) {
|
|
2541
|
-
if (this.isObjectOrArray(source) && seen.includes(source)) {
|
|
2542
|
-
return this.shallowCopy(source);
|
|
2543
|
-
}
|
|
2544
|
-
if (this.isObjectOrArray(source)) {
|
|
2545
|
-
seen.push(source);
|
|
2546
|
-
}
|
|
2547
|
-
if (Array.isArray(source)) {
|
|
2548
|
-
return source.map((item) => this._recursiveCloneAndExecuteFunctions(item, seen));
|
|
2549
|
-
} else if (source instanceof Date) {
|
|
2550
|
-
return new Date(source.getTime());
|
|
2551
|
-
} else if (this.isObject(source)) {
|
|
2552
|
-
return Object.getOwnPropertyNames(source).reduce((o, prop) => {
|
|
2553
|
-
const descriptor = Object.getOwnPropertyDescriptor(source, prop);
|
|
2554
|
-
if (descriptor) {
|
|
2555
|
-
Object.defineProperty(o, prop, descriptor);
|
|
2556
|
-
const value = source[prop];
|
|
2557
|
-
o[prop] = typeof value === "function" ? value() : this._recursiveCloneAndExecuteFunctions(value, seen);
|
|
2558
|
-
}
|
|
2559
|
-
return o;
|
|
2560
|
-
}, Object.create(Object.getPrototypeOf(source)));
|
|
2561
|
-
} else {
|
|
2562
|
-
return source;
|
|
2563
|
-
}
|
|
2564
|
-
}
|
|
2565
|
-
isObjectOrArray(value) {
|
|
2566
|
-
return typeof value === "object" && value !== null;
|
|
2567
|
-
}
|
|
2568
|
-
isObject(value) {
|
|
2569
|
-
return typeof value === "object" && !Array.isArray(value) && value !== null;
|
|
2570
|
-
}
|
|
2571
|
-
shallowCopy(source) {
|
|
2572
|
-
if (Array.isArray(source)) {
|
|
2573
|
-
return [...source];
|
|
2574
|
-
} else {
|
|
2575
|
-
return { ...source };
|
|
2576
|
-
}
|
|
2577
|
-
}
|
|
2578
|
-
_toLogObj(args, clonedLogObj = {}) {
|
|
2579
|
-
args = args?.map((arg) => runtime.isError(arg) ? this._toErrorObject(arg) : arg);
|
|
2580
|
-
if (this.settings.argumentsArrayName == null) {
|
|
2581
|
-
if (args.length === 1 && !Array.isArray(args[0]) && runtime.isBuffer(args[0]) !== true && !(args[0] instanceof Date)) {
|
|
2582
|
-
clonedLogObj = typeof args[0] === "object" && args[0] != null ? { ...args[0], ...clonedLogObj } : { 0: args[0], ...clonedLogObj };
|
|
2583
|
-
} else {
|
|
2584
|
-
clonedLogObj = { ...clonedLogObj, ...args };
|
|
2585
|
-
}
|
|
2586
|
-
} else {
|
|
2587
|
-
clonedLogObj = {
|
|
2588
|
-
...clonedLogObj,
|
|
2589
|
-
[this.settings.argumentsArrayName]: args
|
|
2590
|
-
};
|
|
2591
|
-
}
|
|
2592
|
-
return clonedLogObj;
|
|
2593
|
-
}
|
|
2594
|
-
_cloneError(error) {
|
|
2595
|
-
const cloned = new error.constructor;
|
|
2596
|
-
Object.getOwnPropertyNames(error).forEach((key) => {
|
|
2597
|
-
cloned[key] = error[key];
|
|
2598
|
-
});
|
|
2599
|
-
return cloned;
|
|
2600
|
-
}
|
|
2601
|
-
_toErrorObject(error, depth = 0, seen = new Set) {
|
|
2602
|
-
if (!seen.has(error)) {
|
|
2603
|
-
seen.add(error);
|
|
2604
|
-
}
|
|
2605
|
-
const errorObject = {
|
|
2606
|
-
nativeError: error,
|
|
2607
|
-
name: error.name ?? "Error",
|
|
2608
|
-
message: error.message,
|
|
2609
|
-
stack: runtime.getErrorTrace(error)
|
|
2610
|
-
};
|
|
2611
|
-
if (depth >= this.maxErrorCauseDepth) {
|
|
2612
|
-
return errorObject;
|
|
2613
|
-
}
|
|
2614
|
-
const causeValue = error.cause;
|
|
2615
|
-
if (causeValue != null) {
|
|
2616
|
-
const normalizedCause = toError(causeValue);
|
|
2617
|
-
if (!seen.has(normalizedCause)) {
|
|
2618
|
-
errorObject.cause = this._toErrorObject(normalizedCause, depth + 1, seen);
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
|
-
return errorObject;
|
|
2622
|
-
}
|
|
2623
|
-
_addMetaToLogObj(logObj, logLevelId, logLevelName) {
|
|
2624
|
-
return {
|
|
2625
|
-
...logObj,
|
|
2626
|
-
[this.settings.metaProperty]: runtime.getMeta(logLevelId, logLevelName, this.stackDepthLevel, !this.captureStackForMeta, this.settings.name, this.settings.parentNames)
|
|
2627
|
-
};
|
|
2628
|
-
}
|
|
2629
|
-
_shouldCaptureStack() {
|
|
2630
|
-
if (this.settings.hideLogPositionForProduction) {
|
|
2631
|
-
return false;
|
|
2632
|
-
}
|
|
2633
|
-
if (this.settings.type === "json") {
|
|
2634
|
-
return true;
|
|
2635
|
-
}
|
|
2636
|
-
const template = this.settings.prettyLogTemplate ?? "";
|
|
2637
|
-
const stackPlaceholders = /{{\s*(file(Name|Path|Line|PathWithLine|NameWithLine)|fullFilePath)\s*}}/;
|
|
2638
|
-
if (stackPlaceholders.test(template)) {
|
|
2639
|
-
return true;
|
|
2640
|
-
}
|
|
2641
|
-
return false;
|
|
2642
|
-
}
|
|
2643
|
-
_prettyFormatLogObjMeta(logObjMeta) {
|
|
2644
|
-
return buildPrettyMeta(this.settings, logObjMeta).text;
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
|
|
2648
|
-
// ../../node_modules/.bun/tslog@4.10.2/node_modules/tslog/esm/index.js
|
|
2649
|
-
class Logger extends BaseLogger {
|
|
2650
|
-
constructor(settings, logObj) {
|
|
2651
|
-
const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
2652
|
-
const normalizedSettings = { ...settings ?? {} };
|
|
2653
|
-
if (isBrowser) {
|
|
2654
|
-
normalizedSettings.stylePrettyLogs = settings?.stylePrettyLogs ?? true;
|
|
2655
|
-
}
|
|
2656
|
-
super(normalizedSettings, logObj, Number.NaN);
|
|
2657
|
-
}
|
|
2658
|
-
log(logLevelId, logLevelName, ...args) {
|
|
2659
|
-
return super.log(logLevelId, logLevelName, ...args);
|
|
2660
|
-
}
|
|
2661
|
-
silly(...args) {
|
|
2662
|
-
return super.log(0, "SILLY", ...args);
|
|
2663
|
-
}
|
|
2664
|
-
trace(...args) {
|
|
2665
|
-
return super.log(1, "TRACE", ...args);
|
|
2666
|
-
}
|
|
2667
|
-
debug(...args) {
|
|
2668
|
-
return super.log(2, "DEBUG", ...args);
|
|
2669
|
-
}
|
|
2670
|
-
info(...args) {
|
|
2671
|
-
return super.log(3, "INFO", ...args);
|
|
2672
|
-
}
|
|
2673
|
-
warn(...args) {
|
|
2674
|
-
return super.log(4, "WARN", ...args);
|
|
2675
|
-
}
|
|
2676
|
-
error(...args) {
|
|
2677
|
-
return super.log(5, "ERROR", ...args);
|
|
2678
|
-
}
|
|
2679
|
-
fatal(...args) {
|
|
2680
|
-
return super.log(6, "FATAL", ...args);
|
|
2681
|
-
}
|
|
2682
|
-
getSubLogger(settings, logObj) {
|
|
2683
|
-
return super.getSubLogger(settings, logObj);
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2687
|
-
// src/utils/logger.ts
|
|
2688
|
-
var logger_NiceError = new Logger({
|
|
2689
|
-
name: "NiceErrorLogger"
|
|
2690
|
-
});
|
|
2691
|
-
var logger_NiceError_testing = logger_NiceError.getSubLogger({
|
|
2692
|
-
name: "NiceErrorTestingLogger"
|
|
2693
|
-
});
|
|
2694
|
-
|
|
2695
|
-
// src/utils/inspectPotentialError/inspectPotentialError.ts
|
|
2696
|
-
function interpretMessagePackedError(parsedError) {
|
|
2697
|
-
let packedErrorStr;
|
|
2698
|
-
if (typeof parsedError.message === "string" && parsedError.message.includes(DUR_OBJ_PACK_PREFIX) && parsedError.message.includes(DUR_OBJ_PACK_SUFFIX)) {
|
|
2699
|
-
packedErrorStr = parsedError.message;
|
|
2700
|
-
}
|
|
2701
|
-
if (typeof parsedError.cause === "string" && parsedError.cause.includes(DUR_OBJ_PACK_PREFIX) && parsedError.cause.includes(DUR_OBJ_PACK_SUFFIX)) {
|
|
2702
|
-
packedErrorStr = parsedError.cause;
|
|
2703
|
-
}
|
|
2704
|
-
if (packedErrorStr != null) {
|
|
2705
|
-
const jsonStr = packedErrorStr.split(DUR_OBJ_PACK_PREFIX)[1].split(DUR_OBJ_PACK_SUFFIX)[0];
|
|
2706
|
-
try {
|
|
2707
|
-
const errorObj = JSON.parse(jsonStr);
|
|
2708
|
-
if (isNiceErrorObject(errorObj)) {
|
|
2709
|
-
return {
|
|
2710
|
-
type: "niceErrorObject" /* niceErrorObject */,
|
|
2711
|
-
niceErrorObject: errorObj
|
|
2712
|
-
};
|
|
2713
|
-
}
|
|
2714
|
-
} catch {}
|
|
2715
|
-
}
|
|
2716
|
-
return null;
|
|
2717
|
-
}
|
|
2718
|
-
var inspectPotentialError = (potentialError) => {
|
|
2719
|
-
if (potentialError == null) {
|
|
2720
|
-
return {
|
|
2721
|
-
type: "nullish" /* nullish */,
|
|
2722
|
-
value: potentialError
|
|
2723
|
-
};
|
|
2724
|
-
}
|
|
2725
|
-
if (typeof potentialError === "number") {
|
|
2726
|
-
return {
|
|
2727
|
-
type: "jsDataType" /* jsDataType */,
|
|
2728
|
-
jsDataType: "number",
|
|
2729
|
-
jsDataValue: potentialError
|
|
2730
|
-
};
|
|
2731
|
-
}
|
|
2732
|
-
if (typeof potentialError === "boolean") {
|
|
2733
|
-
return {
|
|
2734
|
-
type: "jsDataType" /* jsDataType */,
|
|
2735
|
-
jsDataType: "boolean",
|
|
2736
|
-
jsDataValue: potentialError
|
|
2737
|
-
};
|
|
2738
|
-
}
|
|
2739
|
-
let parsedError = potentialError;
|
|
2740
|
-
if (typeof potentialError === "string") {
|
|
2741
|
-
if (potentialError.includes("{") && potentialError.includes("name")) {
|
|
2742
|
-
try {
|
|
2743
|
-
parsedError = JSON.parse(potentialError);
|
|
2744
|
-
} catch {
|
|
2745
|
-
return {
|
|
2746
|
-
type: "jsDataType" /* jsDataType */,
|
|
2747
|
-
jsDataType: "string",
|
|
2748
|
-
jsDataValue: potentialError
|
|
2749
|
-
};
|
|
2750
|
-
}
|
|
2751
|
-
} else {
|
|
2752
|
-
return {
|
|
2753
|
-
type: "jsDataType" /* jsDataType */,
|
|
2754
|
-
jsDataType: "string",
|
|
2755
|
-
jsDataValue: potentialError
|
|
2756
|
-
};
|
|
2757
|
-
}
|
|
2758
|
-
}
|
|
2759
|
-
if (typeof parsedError !== "object" || parsedError == null) {
|
|
2760
|
-
logger_NiceError.warn({
|
|
2761
|
-
message: "Received a potential error that is a primitive data type other than string, number, or boolean. This is unexpected and may indicate an issue with error handling in the code.",
|
|
2762
|
-
potentialError
|
|
2763
|
-
});
|
|
2764
|
-
return {
|
|
2765
|
-
jsDataValue: potentialError,
|
|
2766
|
-
type: "jsOther" /* jsOther */
|
|
2767
|
-
};
|
|
2768
|
-
}
|
|
2769
|
-
if (parsedError instanceof NiceError) {
|
|
2770
|
-
return {
|
|
2771
|
-
type: "niceError" /* niceError */,
|
|
2772
|
-
niceError: parsedError
|
|
2773
|
-
};
|
|
2774
|
-
}
|
|
2775
|
-
if (isNiceErrorObject(parsedError)) {
|
|
2776
|
-
return {
|
|
2777
|
-
type: "niceErrorObject" /* niceErrorObject */,
|
|
2778
|
-
niceErrorObject: parsedError
|
|
2779
|
-
};
|
|
2780
|
-
}
|
|
2781
|
-
if (parsedError instanceof Error) {
|
|
2782
|
-
const durObjResult = interpretMessagePackedError(parsedError);
|
|
2783
|
-
if (durObjResult != null) {
|
|
2784
|
-
return durObjResult;
|
|
2785
|
-
}
|
|
2786
|
-
return {
|
|
2787
|
-
type: "jsError" /* jsError */,
|
|
2788
|
-
jsError: parsedError
|
|
2789
|
-
};
|
|
2790
|
-
}
|
|
2791
|
-
if (isRegularErrorJsonObject(parsedError)) {
|
|
2792
|
-
const durObjResult = interpretMessagePackedError(parsedError);
|
|
2793
|
-
if (durObjResult != null) {
|
|
2794
|
-
return durObjResult;
|
|
2795
|
-
}
|
|
2796
|
-
return {
|
|
2797
|
-
type: "jsErrorObject" /* jsErrorObject */,
|
|
2798
|
-
jsErrorObject: parsedError
|
|
2799
|
-
};
|
|
2800
|
-
}
|
|
2801
|
-
return {
|
|
2802
|
-
type: "jsDataType" /* jsDataType */,
|
|
2803
|
-
jsDataType: "object",
|
|
2804
|
-
jsDataValue: parsedError
|
|
2805
|
-
};
|
|
2806
|
-
};
|
|
2807
|
-
|
|
2808
|
-
// src/utils/castNiceError.ts
|
|
2809
|
-
var castNiceError = (error) => {
|
|
2810
|
-
const inspected = inspectPotentialError(error);
|
|
2811
|
-
switch (inspected.type) {
|
|
2812
|
-
case "niceError" /* niceError */:
|
|
2813
|
-
return inspected.niceError;
|
|
2814
|
-
case "niceErrorObject" /* niceErrorObject */: {
|
|
2815
|
-
const obj = inspected.niceErrorObject;
|
|
2816
|
-
return new NiceError(obj);
|
|
2817
|
-
}
|
|
2818
|
-
case "jsError" /* jsError */: {
|
|
2819
|
-
return err_cast_not_nice.fromContext({
|
|
2820
|
-
["native_error" /* js_error */]: inspected
|
|
2821
|
-
}).withOriginError(inspected.jsError);
|
|
2822
|
-
}
|
|
2823
|
-
case "jsErrorObject" /* jsErrorObject */: {
|
|
2824
|
-
const err2 = err_cast_not_nice.fromContext({
|
|
2825
|
-
["js_error_like_object" /* js_error_like_object */]: inspected
|
|
2826
|
-
});
|
|
2827
|
-
err2.cause = inspected.jsErrorObject;
|
|
2828
|
-
return err2;
|
|
2829
|
-
}
|
|
2830
|
-
case "nullish" /* nullish */:
|
|
2831
|
-
return err_cast_not_nice.fromContext({
|
|
2832
|
-
["nullish_value" /* nullish_value */]: inspected
|
|
2833
|
-
});
|
|
2834
|
-
case "jsDataType" /* jsDataType */: {
|
|
2835
|
-
return err_cast_not_nice.fromContext({
|
|
2836
|
-
["js_data_type" /* js_data_type */]: inspected
|
|
2837
|
-
});
|
|
2838
|
-
}
|
|
2839
|
-
default:
|
|
2840
|
-
return err_cast_not_nice.fromContext({
|
|
2841
|
-
["js_other" /* js_other */]: inspected
|
|
2842
|
-
});
|
|
2843
|
-
}
|
|
2844
|
-
};
|
|
2845
|
-
|
|
2846
|
-
// src/utils/castAndHydrate.ts
|
|
2847
|
-
function castAndHydrate(value, niceErrorDefined) {
|
|
2848
|
-
const casted = castNiceError(value);
|
|
2849
|
-
if (niceErrorDefined.isExact(casted)) {
|
|
2850
|
-
return niceErrorDefined.hydrate(casted);
|
|
2851
|
-
}
|
|
2852
|
-
return casted;
|
|
2853
|
-
}
|
|
2854
|
-
// src/utils/matchFirst.ts
|
|
2855
|
-
function matchFirst(error, handlers) {
|
|
2856
|
-
for (const id of error.getIds()) {
|
|
2857
|
-
const handler = handlers[id];
|
|
2858
|
-
if (typeof handler === "function") {
|
|
2859
|
-
const context = error.getContext(id);
|
|
2860
|
-
return handler(context);
|
|
2861
|
-
}
|
|
2862
|
-
}
|
|
2863
|
-
if (typeof handlers._ === "function") {
|
|
2864
|
-
return handlers._();
|
|
2865
|
-
}
|
|
2866
|
-
return;
|
|
2867
|
-
}
|
|
2868
|
-
export {
|
|
2869
|
-
msgPack,
|
|
2870
|
-
matchFirst,
|
|
2871
|
-
isRegularErrorJsonObject,
|
|
2872
|
-
isNiceErrorObject,
|
|
2873
|
-
forIds,
|
|
2874
|
-
forId,
|
|
2875
|
-
forDomain,
|
|
2876
|
-
err_nice_handler,
|
|
2877
|
-
err_nice,
|
|
2878
|
-
err_cast_not_nice,
|
|
2879
|
-
err,
|
|
2880
|
-
defineNiceError,
|
|
2881
|
-
causePack,
|
|
2882
|
-
castNiceError,
|
|
2883
|
-
castAndHydrate,
|
|
2884
|
-
NiceErrorHydrated,
|
|
2885
|
-
NiceErrorHandler,
|
|
2886
|
-
NiceErrorDomain,
|
|
2887
|
-
NiceError,
|
|
2888
|
-
EErrorPackType,
|
|
2889
|
-
EErrorHandlerTargetType,
|
|
2890
|
-
EErrId_CastNotNice
|
|
2891
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "./internal";
|
|
3
|
+
export * from "./NiceError/NiceError";
|
|
4
|
+
export * from "./NiceError/NiceError.types";
|
|
5
|
+
export * from "./NiceError/NiceErrorHydrated";
|
|
6
|
+
export * from "./NiceErrorDefined/defineNiceError";
|
|
7
|
+
export * from "./NiceErrorDefined/err";
|
|
8
|
+
export * from "./NiceErrorDefined/NiceErrorDefined";
|
|
9
|
+
export * from "./NiceErrorHandler/handleWith";
|
|
10
|
+
export * from "./NiceErrorHandler/NiceErrorHandler";
|
|
11
|
+
export * from "./NiceErrorHandler/NiceErrorHandler.types";
|
|
12
|
+
export * from "./utils/castAndHydrate";
|
|
13
|
+
export * from "./utils/castNiceError";
|
|
14
|
+
export * from "./utils/isNiceErrorObject";
|
|
15
|
+
export * from "./utils/isRegularErrorObject";
|
|
16
|
+
export * from "./utils/matchFirst";
|
|
17
|
+
export * from "./utils/packError/causePack";
|
|
18
|
+
export * from "./utils/packError/msgPack";
|
|
19
|
+
export * from "./utils/packError/packError.enums";
|