@visulima/error 4.1.0 → 4.2.0
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/CHANGELOG.md +10 -0
- package/README.md +103 -4
- package/dist/code-frame/index.cjs +6 -6
- package/dist/code-frame/index.d.cts +3 -23
- package/dist/code-frame/index.d.mts +3 -23
- package/dist/code-frame/index.d.ts +3 -23
- package/dist/code-frame/index.mjs +6 -6
- package/dist/error/index.cjs +1 -1
- package/dist/error/index.d.cts +44 -22
- package/dist/error/index.d.mts +44 -22
- package/dist/error/index.d.ts +44 -22
- package/dist/error/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +1 -1
- package/dist/shared/error.B5KA_10i.cjs +18 -0
- package/dist/shared/error.BoX3yBJ9.mjs +18 -0
- package/dist/shared/error.CrVmNoPV.d.cts +25 -0
- package/dist/shared/error.CrVmNoPV.d.mts +25 -0
- package/dist/shared/error.CrVmNoPV.d.ts +25 -0
- package/package.json +15 -4
- package/dist/shared/error.CVJAi2IP.mjs +0 -1
- package/dist/shared/error.uFKIz5VX.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## @visulima/error [4.2.0](https://github.com/visulima/visulima/compare/@visulima/error@4.1.0...@visulima/error@4.2.0) (2024-07-02)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **error:** added renderError, added cause to visulima-error ([#449](https://github.com/visulima/visulima/issues/449)) ([4e78638](https://github.com/visulima/visulima/commit/4e7863890ccbc66a1427d4e6fd4c1879cf448b77))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* updated dev dependencies ([34df456](https://github.com/visulima/visulima/commit/34df4569f2fc074823a406c44a131c8fbae2b147))
|
|
10
|
+
|
|
1
11
|
## @visulima/error [4.1.0](https://github.com/visulima/visulima/compare/@visulima/error@4.0.0...@visulima/error@4.1.0) (2024-07-01)
|
|
2
12
|
|
|
3
13
|
### Features
|
package/README.md
CHANGED
|
@@ -206,11 +206,11 @@ Currently supported browsers/platforms:
|
|
|
206
206
|
- Opera (Chromium based)
|
|
207
207
|
|
|
208
208
|
```ts
|
|
209
|
-
import {
|
|
209
|
+
import { parseStacktrace } from "@visulima/error";
|
|
210
210
|
|
|
211
211
|
const error = new Error("My error message");
|
|
212
212
|
|
|
213
|
-
const stack =
|
|
213
|
+
const stack = parseStacktrace(error);
|
|
214
214
|
|
|
215
215
|
console.log(stack);
|
|
216
216
|
|
|
@@ -254,6 +254,102 @@ const errorString = JSON.stringify(errorObject);
|
|
|
254
254
|
const newErrorObject = JSON.parse(errorString);
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
+
## renderError - pretty print an error
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
import { renderError } from "@visulima/error";
|
|
261
|
+
|
|
262
|
+
const error = new Error("This is an error message");
|
|
263
|
+
|
|
264
|
+
console.log(renderError(error));
|
|
265
|
+
|
|
266
|
+
// Error: This is an error message
|
|
267
|
+
//
|
|
268
|
+
// at <unknown> file:///home/visulima/visulima/examples/error/node/render-error.js:5
|
|
269
|
+
// 1 | import { renderError } from "@visulima/error";
|
|
270
|
+
// 2 |
|
|
271
|
+
// 3 | const error = new Error("This is an error message");
|
|
272
|
+
// 4 |
|
|
273
|
+
// ❯ 5 | console.log(renderError(new Error("This is an error message")));
|
|
274
|
+
// | ^
|
|
275
|
+
// 6 |
|
|
276
|
+
//
|
|
277
|
+
// at ModuleJob.run node:internal/modules/esm/module_job:195
|
|
278
|
+
// at async ModuleLoader.import node:internal/modules/esm/loader:336
|
|
279
|
+
// at async loadESM node:internal/process/esm_loader:34
|
|
280
|
+
// at async handleMainPromise node:internal/modules/run_main:106
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### colorized output
|
|
284
|
+
|
|
285
|
+
Use the `@visulima/colorize`, `chalk` or some other package to colorize the output.
|
|
286
|
+
|
|
287
|
+

|
|
288
|
+
|
|
289
|
+
### API
|
|
290
|
+
|
|
291
|
+
#### error
|
|
292
|
+
|
|
293
|
+
Type: `AggregateError | Error | VisulimaError` \
|
|
294
|
+
The error to render.
|
|
295
|
+
|
|
296
|
+
#### options
|
|
297
|
+
|
|
298
|
+
Type: `object`
|
|
299
|
+
|
|
300
|
+
##### options.color
|
|
301
|
+
|
|
302
|
+
Type: `object` \
|
|
303
|
+
The color options.
|
|
304
|
+
|
|
305
|
+
##### options.cwd
|
|
306
|
+
|
|
307
|
+
Type: `string`
|
|
308
|
+
|
|
309
|
+
The current working directory.
|
|
310
|
+
|
|
311
|
+
##### options.displayShortPath
|
|
312
|
+
|
|
313
|
+
Type: `boolean` \
|
|
314
|
+
Default: `false`
|
|
315
|
+
|
|
316
|
+
Display the short path.
|
|
317
|
+
|
|
318
|
+
##### options.framesMaxLimit
|
|
319
|
+
|
|
320
|
+
Type: `number` \
|
|
321
|
+
Default: `Number.Infinity`
|
|
322
|
+
|
|
323
|
+
The maximum number of frames to display.
|
|
324
|
+
|
|
325
|
+
##### options.hideErrorCauseCodeView
|
|
326
|
+
|
|
327
|
+
Type: `boolean` \
|
|
328
|
+
Default: `false`
|
|
329
|
+
|
|
330
|
+
Hide the error cause code view.
|
|
331
|
+
|
|
332
|
+
##### options.hideErrorCodeView
|
|
333
|
+
|
|
334
|
+
Type: `boolean` \
|
|
335
|
+
Default: `false`
|
|
336
|
+
|
|
337
|
+
Hide the error code view.
|
|
338
|
+
|
|
339
|
+
##### options.hideErrorTitle
|
|
340
|
+
|
|
341
|
+
Type: `boolean` \
|
|
342
|
+
Default: `false`
|
|
343
|
+
|
|
344
|
+
Hide the error title.
|
|
345
|
+
|
|
346
|
+
##### options.hideMessage
|
|
347
|
+
|
|
348
|
+
Type: `boolean` \
|
|
349
|
+
Default: `false`
|
|
350
|
+
|
|
351
|
+
Hide the error message.
|
|
352
|
+
|
|
257
353
|
## Supported Node.js Versions
|
|
258
354
|
|
|
259
355
|
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
@@ -275,7 +371,6 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
275
371
|
### Related Projects
|
|
276
372
|
|
|
277
373
|
- [baseerr](https://github.com/tjmehta/baseerr): merge another error with additional properties.
|
|
278
|
-
- [callsite-record](https://github.com/inikulin/callsite-record): create a fancy log entries for errors and function call sites.
|
|
279
374
|
- [callsites](https://github.com/sindresorhus/callsites): get callsites from the V8 stack trace API.
|
|
280
375
|
- [explain-error](https://github.com/dominictarr/explain-error): wrap an error with additional explanation.
|
|
281
376
|
- [error-wrapper](https://github.com/spudly/error-wrapper): merges the stack of another error to its own.
|
|
@@ -284,11 +379,15 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
284
379
|
- [clarify](https://github.com/AndreasMadsen/clarify): remove node related stack trace noise.
|
|
285
380
|
- [piotr-szewczyk/stacktrace-parser-node](https://github.com/piotr-szewczyk/stacktrace-parser-node)
|
|
286
381
|
- [pretty-error](https://github.com/AriaMinaei/pretty-error): make the call stacks clear.
|
|
382
|
+
- [node-pretty-exceptions](https://github.com/ahmadnassri/node-pretty-exceptions) - Pretty and more helpful uncaught exceptions, automatically
|
|
383
|
+
- [youch-terminal](https://github.com/poppinss/youch-terminal/tree/develop) - Display youch error message on terminal
|
|
287
384
|
- [ono](https://github.com/bigstickcarpet/ono): allow different types of error to be thrown.
|
|
288
|
-
- [ololog](https://github.com/xpl/ololog): another logger with a similar motivation but only support console.log as its sole transport.
|
|
289
385
|
- [stacktracejs/error-stack-parser](https://github.com/stacktracejs/error-stack-parser)
|
|
290
386
|
- [marvinhagemeister/errorstacks](https://github.com/marvinhagemeister/errorstacks) Tiny library to parse error stack traces
|
|
291
387
|
- [getsentry/sentry-javascript](https://github.com/getsentry/sentry-javascript)
|
|
388
|
+
- [serialize-error](https://github.com/sindresorhus/serialize-error) - Serialize/deserialize an error into a plain object
|
|
389
|
+
- [baseerr](https://github.com/tjmehta/baseerr): merge another error with additional properties.
|
|
390
|
+
- [callsite-record](https://github.com/inikulin/callsite-record) - Create fancy log entries for errors and function call sites
|
|
292
391
|
|
|
293
392
|
## License
|
|
294
393
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`),"normalizeLF"),T=globalThis.process||Object.create(null),O={versions:{}},
|
|
3
|
-
`);typeof n?.tabWidth=="number"&&(i=i.map(r=>r.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:l,start:m}=R(e,i,n.linesAbove,n.linesBelow),u=String(o).length,{gutter:g,marker:
|
|
4
|
-
`,g(y.replaceAll(/\d/g," "))," ",
|
|
5
|
-
`);return n.message&&!f&&(a
|
|
6
|
-
${a}`),a},"codeFrame");exports.CODE_FRAME_POINTER=
|
|
1
|
+
"use strict";var F=Object.defineProperty;var v=(t,e)=>F(t,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var L=Object.defineProperty,P=v((t,e)=>L(t,"name",{value:e,configurable:!0}),"r$1");const S=P(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
2
|
+
`),"normalizeLF"),T=globalThis.process||Object.create(null),O={versions:{}},x=new Proxy(T,{get(t,e){if(e in t)return t[e];if(e in O)return O[e]}});var _=Object.defineProperty,N=v((t,e)=>_(t,"name",{value:e,configurable:!0}),"b");const R=N((t,e,d,n)=>{const f={column:0,line:-1,...t.start},i={...f,...t.end},o=f.line,l=f.column,m=i.line,u=i.column;let g=Math.max(o-(d+1),0),p=Math.min(e.length,m+n);o===-1&&(g=0),m===-1&&(p=e.length);const b=m-o,a={};if(b)for(let r=0;r<=b;r++){const s=r+o;if(!l)a[s]=!0;else if(r===0){const c=e[s-1]?.length;a[s]=[l,(c??0)-l+1]}else if(r===b)a[s]=[0,u];else{const c=e[s-r]?.length;a[s]=[0,c]}}else l===u?a[o]=l?[l,0]:!0:a[o]=[l,(u??0)-(l??0)];return{end:p,markerLines:a,start:g}},"getMarkerLines");var W=Object.defineProperty,$=v((t,e)=>W(t,"name",{value:e,configurable:!0}),"o");const j=x.platform==="win32"&&!x.env?.WT_SESSION?">":"❯",C=$((t,e,d)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...d,color:{gutter:$(r=>r,"gutter"),marker:$(r=>r,"marker"),message:$(r=>r,"message"),...d?.color}},f=e.start&&typeof e.start.column=="number";let i=S(t).split(`
|
|
3
|
+
`);typeof n?.tabWidth=="number"&&(i=i.map(r=>r.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:l,start:m}=R(e,i,n.linesAbove,n.linesBelow),u=String(o).length,{gutter:g,marker:p,message:b}=n.color;let a=i.slice(m,o).map((r,s)=>{const c=m+1+s,h=l[c],k=` ${c}`.slice(-u),M=!l[c+1],y=` ${k}${n.showGutter?" |":""}`;if(h){let A="";if(Array.isArray(h)){const w=r.replaceAll(/[^\t]/g," ").slice(0,Math.max(h[0]-1,0)),E=h[1]||1;A=[`
|
|
4
|
+
`,n.prefix+g(y.replaceAll(/\d/g," "))," ",w,p("^").repeat(E)].join(""),M&&n.message&&(A+=` ${b(n.message)}`)}return[n.prefix+p(j),g(y),r.length>0?` ${r}`:"",A].join("")}return n.prefix+` ${g(y)}${r.length>0?` ${r}`:""}`}).join(`
|
|
5
|
+
`);return n.message&&!f&&(a=n.prefix+`${" ".repeat(u+1)}${n.message}
|
|
6
|
+
${a}`),a},"codeFrame");exports.CODE_FRAME_POINTER=j;exports.codeFrame=C;
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
line: number;
|
|
4
|
-
};
|
|
5
|
-
type CodeFrameNodeLocation = {
|
|
6
|
-
end?: CodeFrameLocation;
|
|
7
|
-
start: CodeFrameLocation;
|
|
8
|
-
};
|
|
9
|
-
type ColorizeMethod = (value: string) => string;
|
|
10
|
-
type CodeFrameOptions = {
|
|
11
|
-
color?: {
|
|
12
|
-
gutter?: ColorizeMethod;
|
|
13
|
-
marker?: ColorizeMethod;
|
|
14
|
-
message?: ColorizeMethod;
|
|
15
|
-
};
|
|
16
|
-
linesAbove?: number;
|
|
17
|
-
linesBelow?: number;
|
|
18
|
-
message?: string;
|
|
19
|
-
showGutter?: boolean;
|
|
20
|
-
showLineNumbers?: boolean;
|
|
21
|
-
tabWidth?: number | false;
|
|
22
|
-
};
|
|
1
|
+
import { a as CodeFrameNodeLocation, b as CodeFrameOptions } from '../shared/error.CrVmNoPV.cjs';
|
|
2
|
+
export { C as CodeFrameLocation, c as ColorizeMethod } from '../shared/error.CrVmNoPV.cjs';
|
|
23
3
|
|
|
24
4
|
declare const CODE_FRAME_POINTER: string;
|
|
25
5
|
declare const codeFrame: (source: string, loc: CodeFrameNodeLocation, options?: CodeFrameOptions) => string;
|
|
26
6
|
|
|
27
|
-
export { CODE_FRAME_POINTER,
|
|
7
|
+
export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
line: number;
|
|
4
|
-
};
|
|
5
|
-
type CodeFrameNodeLocation = {
|
|
6
|
-
end?: CodeFrameLocation;
|
|
7
|
-
start: CodeFrameLocation;
|
|
8
|
-
};
|
|
9
|
-
type ColorizeMethod = (value: string) => string;
|
|
10
|
-
type CodeFrameOptions = {
|
|
11
|
-
color?: {
|
|
12
|
-
gutter?: ColorizeMethod;
|
|
13
|
-
marker?: ColorizeMethod;
|
|
14
|
-
message?: ColorizeMethod;
|
|
15
|
-
};
|
|
16
|
-
linesAbove?: number;
|
|
17
|
-
linesBelow?: number;
|
|
18
|
-
message?: string;
|
|
19
|
-
showGutter?: boolean;
|
|
20
|
-
showLineNumbers?: boolean;
|
|
21
|
-
tabWidth?: number | false;
|
|
22
|
-
};
|
|
1
|
+
import { a as CodeFrameNodeLocation, b as CodeFrameOptions } from '../shared/error.CrVmNoPV.mjs';
|
|
2
|
+
export { C as CodeFrameLocation, c as ColorizeMethod } from '../shared/error.CrVmNoPV.mjs';
|
|
23
3
|
|
|
24
4
|
declare const CODE_FRAME_POINTER: string;
|
|
25
5
|
declare const codeFrame: (source: string, loc: CodeFrameNodeLocation, options?: CodeFrameOptions) => string;
|
|
26
6
|
|
|
27
|
-
export { CODE_FRAME_POINTER,
|
|
7
|
+
export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
line: number;
|
|
4
|
-
};
|
|
5
|
-
type CodeFrameNodeLocation = {
|
|
6
|
-
end?: CodeFrameLocation;
|
|
7
|
-
start: CodeFrameLocation;
|
|
8
|
-
};
|
|
9
|
-
type ColorizeMethod = (value: string) => string;
|
|
10
|
-
type CodeFrameOptions = {
|
|
11
|
-
color?: {
|
|
12
|
-
gutter?: ColorizeMethod;
|
|
13
|
-
marker?: ColorizeMethod;
|
|
14
|
-
message?: ColorizeMethod;
|
|
15
|
-
};
|
|
16
|
-
linesAbove?: number;
|
|
17
|
-
linesBelow?: number;
|
|
18
|
-
message?: string;
|
|
19
|
-
showGutter?: boolean;
|
|
20
|
-
showLineNumbers?: boolean;
|
|
21
|
-
tabWidth?: number | false;
|
|
22
|
-
};
|
|
1
|
+
import { a as CodeFrameNodeLocation, b as CodeFrameOptions } from '../shared/error.CrVmNoPV.js';
|
|
2
|
+
export { C as CodeFrameLocation, c as ColorizeMethod } from '../shared/error.CrVmNoPV.js';
|
|
23
3
|
|
|
24
4
|
declare const CODE_FRAME_POINTER: string;
|
|
25
5
|
declare const codeFrame: (source: string, loc: CodeFrameNodeLocation, options?: CodeFrameOptions) => string;
|
|
26
6
|
|
|
27
|
-
export { CODE_FRAME_POINTER,
|
|
7
|
+
export { CODE_FRAME_POINTER, CodeFrameNodeLocation, CodeFrameOptions, codeFrame };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),"normalizeLF"),
|
|
3
|
-
`);typeof n?.tabWidth=="number"&&(i=i.map(r=>r.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:l,start:m}=
|
|
4
|
-
`,g(
|
|
5
|
-
`);return n.message&&!f&&(a
|
|
6
|
-
${a}`),a},"codeFrame");export{
|
|
1
|
+
var M=Object.defineProperty;var v=(t,e)=>M(t,"name",{value:e,configurable:!0});var F=Object.defineProperty,P=v((t,e)=>F(t,"name",{value:e,configurable:!0}),"r$1");const E=P(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
2
|
+
`),"normalizeLF"),S=globalThis.process||Object.create(null),y={versions:{}},k=new Proxy(S,{get(t,e){if(e in t)return t[e];if(e in y)return y[e]}});var W=Object.defineProperty,N=v((t,e)=>W(t,"name",{value:e,configurable:!0}),"b");const T=N((t,e,h,n)=>{const f={column:0,line:-1,...t.start},i={...f,...t.end},o=f.line,l=f.column,m=i.line,u=i.column;let g=Math.max(o-(h+1),0),p=Math.min(e.length,m+n);o===-1&&(g=0),m===-1&&(p=e.length);const b=m-o,a={};if(b)for(let r=0;r<=b;r++){const s=r+o;if(!l)a[s]=!0;else if(r===0){const c=e[s-1]?.length;a[s]=[l,(c??0)-l+1]}else if(r===b)a[s]=[0,u];else{const c=e[s-r]?.length;a[s]=[0,c]}}else l===u?a[o]=l?[l,0]:!0:a[o]=[l,(u??0)-(l??0)];return{end:p,markerLines:a,start:g}},"getMarkerLines");var _=Object.defineProperty,$=v((t,e)=>_(t,"name",{value:e,configurable:!0}),"o");const B=k.platform==="win32"&&!k.env?.WT_SESSION?">":"❯",G=$((t,e,h)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...h,color:{gutter:$(r=>r,"gutter"),marker:$(r=>r,"marker"),message:$(r=>r,"message"),...h?.color}},f=e.start&&typeof e.start.column=="number";let i=E(t).split(`
|
|
3
|
+
`);typeof n?.tabWidth=="number"&&(i=i.map(r=>r.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:l,start:m}=T(e,i,n.linesAbove,n.linesBelow),u=String(o).length,{gutter:g,marker:p,message:b}=n.color;let a=i.slice(m,o).map((r,s)=>{const c=m+1+s,d=l[c],j=` ${c}`.slice(-u),w=!l[c+1],x=` ${j}${n.showGutter?" |":""}`;if(d){let A="";if(Array.isArray(d)){const L=r.replaceAll(/[^\t]/g," ").slice(0,Math.max(d[0]-1,0)),O=d[1]||1;A=[`
|
|
4
|
+
`,n.prefix+g(x.replaceAll(/\d/g," "))," ",L,p("^").repeat(O)].join(""),w&&n.message&&(A+=` ${b(n.message)}`)}return[n.prefix+p(B),g(x),r.length>0?` ${r}`:"",A].join("")}return n.prefix+` ${g(x)}${r.length>0?` ${r}`:""}`}).join(`
|
|
5
|
+
`);return n.message&&!f&&(a=n.prefix+`${" ".repeat(u+1)}${n.message}
|
|
6
|
+
${a}`),a},"codeFrame");export{B as CODE_FRAME_POINTER,G as codeFrame};
|
package/dist/error/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../shared/error.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../shared/error.B5KA_10i.cjs");exports.VisulimaError=r.VisulimaError;exports.getErrorCauses=r.i;exports.isVisulimaError=r.isVisulimaError;exports.renderError=r.renderError;exports.serializeError=r.serialize;
|
package/dist/error/index.d.cts
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
4
|
-
aggregateErrors?: SerializedError<ErrorType>[];
|
|
5
|
-
cause?: unknown;
|
|
6
|
-
code?: string;
|
|
7
|
-
message: string;
|
|
8
|
-
name: string;
|
|
9
|
-
raw?: ErrorType;
|
|
10
|
-
stack?: string;
|
|
11
|
-
};
|
|
1
|
+
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.cjs';
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
toJSON: () => SerializedError;
|
|
15
|
-
}
|
|
16
|
-
type Options = {
|
|
17
|
-
exclude?: string[];
|
|
18
|
-
maxDepth?: number;
|
|
19
|
-
useToJSON?: boolean;
|
|
20
|
-
};
|
|
21
|
-
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
3
|
+
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
22
4
|
|
|
23
5
|
interface ErrorProperties {
|
|
6
|
+
cause?: Error | unknown;
|
|
24
7
|
hint?: ErrorHint;
|
|
25
8
|
location?: ErrorLocation;
|
|
26
9
|
message?: string;
|
|
@@ -41,11 +24,50 @@ declare class VisulimaError extends Error {
|
|
|
41
24
|
title: string | undefined;
|
|
42
25
|
hint: ErrorHint | undefined;
|
|
43
26
|
type: string;
|
|
44
|
-
constructor(
|
|
27
|
+
constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
|
|
45
28
|
setLocation(location: ErrorLocation): void;
|
|
46
29
|
setName(name: string): void;
|
|
47
30
|
setMessage(message: string): void;
|
|
48
31
|
setHint(hint: ErrorHint): void;
|
|
49
32
|
}
|
|
50
33
|
|
|
51
|
-
|
|
34
|
+
type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
35
|
+
color: CodeFrameOptions["color"] & {
|
|
36
|
+
fileLine: ColorizeMethod;
|
|
37
|
+
hint: ColorizeMethod;
|
|
38
|
+
method: ColorizeMethod;
|
|
39
|
+
title: ColorizeMethod;
|
|
40
|
+
};
|
|
41
|
+
cwd: string;
|
|
42
|
+
displayShortPath: boolean;
|
|
43
|
+
framesMaxLimit: number;
|
|
44
|
+
hideErrorCauseCodeView: boolean;
|
|
45
|
+
hideErrorCodeView: boolean;
|
|
46
|
+
hideErrorErrorsCodeView: boolean;
|
|
47
|
+
hideErrorTitle: boolean;
|
|
48
|
+
hideMessage: boolean;
|
|
49
|
+
indentation: number | "\t";
|
|
50
|
+
};
|
|
51
|
+
declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
|
|
52
|
+
|
|
53
|
+
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
54
|
+
aggregateErrors?: SerializedError<ErrorType>[];
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
code?: string;
|
|
57
|
+
message: string;
|
|
58
|
+
name: string;
|
|
59
|
+
raw?: ErrorType;
|
|
60
|
+
stack?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
interface JsonError extends Error {
|
|
64
|
+
toJSON: () => SerializedError;
|
|
65
|
+
}
|
|
66
|
+
type Options = {
|
|
67
|
+
exclude?: string[];
|
|
68
|
+
maxDepth?: number;
|
|
69
|
+
useToJSON?: boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
72
|
+
|
|
73
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
package/dist/error/index.d.mts
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
4
|
-
aggregateErrors?: SerializedError<ErrorType>[];
|
|
5
|
-
cause?: unknown;
|
|
6
|
-
code?: string;
|
|
7
|
-
message: string;
|
|
8
|
-
name: string;
|
|
9
|
-
raw?: ErrorType;
|
|
10
|
-
stack?: string;
|
|
11
|
-
};
|
|
1
|
+
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.mjs';
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
toJSON: () => SerializedError;
|
|
15
|
-
}
|
|
16
|
-
type Options = {
|
|
17
|
-
exclude?: string[];
|
|
18
|
-
maxDepth?: number;
|
|
19
|
-
useToJSON?: boolean;
|
|
20
|
-
};
|
|
21
|
-
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
3
|
+
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
22
4
|
|
|
23
5
|
interface ErrorProperties {
|
|
6
|
+
cause?: Error | unknown;
|
|
24
7
|
hint?: ErrorHint;
|
|
25
8
|
location?: ErrorLocation;
|
|
26
9
|
message?: string;
|
|
@@ -41,11 +24,50 @@ declare class VisulimaError extends Error {
|
|
|
41
24
|
title: string | undefined;
|
|
42
25
|
hint: ErrorHint | undefined;
|
|
43
26
|
type: string;
|
|
44
|
-
constructor(
|
|
27
|
+
constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
|
|
45
28
|
setLocation(location: ErrorLocation): void;
|
|
46
29
|
setName(name: string): void;
|
|
47
30
|
setMessage(message: string): void;
|
|
48
31
|
setHint(hint: ErrorHint): void;
|
|
49
32
|
}
|
|
50
33
|
|
|
51
|
-
|
|
34
|
+
type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
35
|
+
color: CodeFrameOptions["color"] & {
|
|
36
|
+
fileLine: ColorizeMethod;
|
|
37
|
+
hint: ColorizeMethod;
|
|
38
|
+
method: ColorizeMethod;
|
|
39
|
+
title: ColorizeMethod;
|
|
40
|
+
};
|
|
41
|
+
cwd: string;
|
|
42
|
+
displayShortPath: boolean;
|
|
43
|
+
framesMaxLimit: number;
|
|
44
|
+
hideErrorCauseCodeView: boolean;
|
|
45
|
+
hideErrorCodeView: boolean;
|
|
46
|
+
hideErrorErrorsCodeView: boolean;
|
|
47
|
+
hideErrorTitle: boolean;
|
|
48
|
+
hideMessage: boolean;
|
|
49
|
+
indentation: number | "\t";
|
|
50
|
+
};
|
|
51
|
+
declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
|
|
52
|
+
|
|
53
|
+
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
54
|
+
aggregateErrors?: SerializedError<ErrorType>[];
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
code?: string;
|
|
57
|
+
message: string;
|
|
58
|
+
name: string;
|
|
59
|
+
raw?: ErrorType;
|
|
60
|
+
stack?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
interface JsonError extends Error {
|
|
64
|
+
toJSON: () => SerializedError;
|
|
65
|
+
}
|
|
66
|
+
type Options = {
|
|
67
|
+
exclude?: string[];
|
|
68
|
+
maxDepth?: number;
|
|
69
|
+
useToJSON?: boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
72
|
+
|
|
73
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
4
|
-
aggregateErrors?: SerializedError<ErrorType>[];
|
|
5
|
-
cause?: unknown;
|
|
6
|
-
code?: string;
|
|
7
|
-
message: string;
|
|
8
|
-
name: string;
|
|
9
|
-
raw?: ErrorType;
|
|
10
|
-
stack?: string;
|
|
11
|
-
};
|
|
1
|
+
import { b as CodeFrameOptions, c as ColorizeMethod } from '../shared/error.CrVmNoPV.js';
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
toJSON: () => SerializedError;
|
|
15
|
-
}
|
|
16
|
-
type Options = {
|
|
17
|
-
exclude?: string[];
|
|
18
|
-
maxDepth?: number;
|
|
19
|
-
useToJSON?: boolean;
|
|
20
|
-
};
|
|
21
|
-
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
3
|
+
declare const getErrorCauses: <E = unknown>(error: E) => E[];
|
|
22
4
|
|
|
23
5
|
interface ErrorProperties {
|
|
6
|
+
cause?: Error | unknown;
|
|
24
7
|
hint?: ErrorHint;
|
|
25
8
|
location?: ErrorLocation;
|
|
26
9
|
message?: string;
|
|
@@ -41,11 +24,50 @@ declare class VisulimaError extends Error {
|
|
|
41
24
|
title: string | undefined;
|
|
42
25
|
hint: ErrorHint | undefined;
|
|
43
26
|
type: string;
|
|
44
|
-
constructor(
|
|
27
|
+
constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties);
|
|
45
28
|
setLocation(location: ErrorLocation): void;
|
|
46
29
|
setName(name: string): void;
|
|
47
30
|
setMessage(message: string): void;
|
|
48
31
|
setHint(hint: ErrorHint): void;
|
|
49
32
|
}
|
|
50
33
|
|
|
51
|
-
|
|
34
|
+
type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
35
|
+
color: CodeFrameOptions["color"] & {
|
|
36
|
+
fileLine: ColorizeMethod;
|
|
37
|
+
hint: ColorizeMethod;
|
|
38
|
+
method: ColorizeMethod;
|
|
39
|
+
title: ColorizeMethod;
|
|
40
|
+
};
|
|
41
|
+
cwd: string;
|
|
42
|
+
displayShortPath: boolean;
|
|
43
|
+
framesMaxLimit: number;
|
|
44
|
+
hideErrorCauseCodeView: boolean;
|
|
45
|
+
hideErrorCodeView: boolean;
|
|
46
|
+
hideErrorErrorsCodeView: boolean;
|
|
47
|
+
hideErrorTitle: boolean;
|
|
48
|
+
hideMessage: boolean;
|
|
49
|
+
indentation: number | "\t";
|
|
50
|
+
};
|
|
51
|
+
declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string;
|
|
52
|
+
|
|
53
|
+
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
|
|
54
|
+
aggregateErrors?: SerializedError<ErrorType>[];
|
|
55
|
+
cause?: unknown;
|
|
56
|
+
code?: string;
|
|
57
|
+
message: string;
|
|
58
|
+
name: string;
|
|
59
|
+
raw?: ErrorType;
|
|
60
|
+
stack?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
interface JsonError extends Error {
|
|
64
|
+
toJSON: () => SerializedError;
|
|
65
|
+
}
|
|
66
|
+
type Options = {
|
|
67
|
+
exclude?: string[];
|
|
68
|
+
maxDepth?: number;
|
|
69
|
+
useToJSON?: boolean;
|
|
70
|
+
};
|
|
71
|
+
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
|
|
72
|
+
|
|
73
|
+
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };
|
package/dist/error/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{V as a,i,a as o,s as
|
|
1
|
+
import{V as a,i,a as e,r as o,s as E}from"../shared/error.BoX3yBJ9.mjs";export{a as VisulimaError,i as getErrorCauses,e as isVisulimaError,o as renderError,E as serializeError};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var c=(r,e)=>y(r,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./code-frame/index.cjs"),
|
|
1
|
+
"use strict";var y=Object.defineProperty;var c=(r,e)=>y(r,"name",{value:e,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./code-frame/index.cjs"),o=require("./shared/error.B5KA_10i.cjs"),E=require("./stacktrace/index.cjs");var d=Object.defineProperty,s=c((r,e)=>d(r,"name",{value:e,configurable:!0}),"l");const u=s((r,e)=>{let n=0,t=e.length-2;for(;n<t;){const i=n+(t-n>>1);if(r<e[i])t=i-1;else if(r>=e[i+1])n=i+1;else{n=i;break}}return n},"binarySearch"),f=s(r=>r.split(/\n|\r(?!\n)/).reduce((e,n)=>(e.push(e.at(-1)+n.length+1),e),[0]),"getLineStartIndexes"),g=s((r,e,n)=>{const t=n?.skipChecks??!1;if(!t&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return{column:0,line:0};if(!t&&(typeof e!="number"||typeof r=="string"&&e>=r.length||Array.isArray(r)&&e+1>=r.at(-1)))return{column:0,line:0};if(typeof r=="string"){const a=f(r),l=u(e,a);return{column:e-a[l]+1,line:l+1}}const i=u(e,r);return{column:e-r[i]+1,line:i+1}},"indexToLineColumn"),p=g;exports.CODE_FRAME_POINTER=m.CODE_FRAME_POINTER;exports.codeFrame=m.codeFrame;exports.VisulimaError=o.VisulimaError;exports.getErrorCauses=o.i;exports.isVisulimaError=o.isVisulimaError;exports.renderError=o.renderError;exports.serializeError=o.serialize;exports.parseStacktrace=E.parseStacktrace;exports.indexToLineColumn=p;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { CODE_FRAME_POINTER,
|
|
2
|
-
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serializeError } from './error/index.cjs';
|
|
1
|
+
export { CODE_FRAME_POINTER, codeFrame } from './code-frame/index.cjs';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.cjs';
|
|
3
3
|
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.cjs';
|
|
4
|
+
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.cjs';
|
|
4
5
|
|
|
5
6
|
declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
|
|
6
7
|
skipChecks: boolean;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { CODE_FRAME_POINTER,
|
|
2
|
-
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serializeError } from './error/index.mjs';
|
|
1
|
+
export { CODE_FRAME_POINTER, codeFrame } from './code-frame/index.mjs';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.mjs';
|
|
3
3
|
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.mjs';
|
|
4
|
+
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.mjs';
|
|
4
5
|
|
|
5
6
|
declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
|
|
6
7
|
skipChecks: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { CODE_FRAME_POINTER,
|
|
2
|
-
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serializeError } from './error/index.js';
|
|
1
|
+
export { CODE_FRAME_POINTER, codeFrame } from './code-frame/index.js';
|
|
2
|
+
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, RenderErrorOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, renderError, serializeError } from './error/index.js';
|
|
3
3
|
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.js';
|
|
4
|
+
export { C as CodeFrameLocation, a as CodeFrameNodeLocation, b as CodeFrameOptions, c as ColorizeMethod } from './shared/error.CrVmNoPV.js';
|
|
4
5
|
|
|
5
6
|
declare const indexToLineColumn: (input: number[] | string, index: number, options?: {
|
|
6
7
|
skipChecks: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var l=(r,e)=>c(r,"name",{value:e,configurable:!0});import{CODE_FRAME_POINTER as
|
|
1
|
+
var c=Object.defineProperty;var l=(r,e)=>c(r,"name",{value:e,configurable:!0});import{CODE_FRAME_POINTER as h,codeFrame as x}from"./code-frame/index.mjs";import{V as b,i as C,a as k,r as v,s as L}from"./shared/error.BoX3yBJ9.mjs";import{parseStacktrace as S}from"./stacktrace/index.mjs";var f=Object.defineProperty,s=l((r,e)=>f(r,"name",{value:e,configurable:!0}),"l");const u=s((r,e)=>{let n=0,o=e.length-2;for(;n<o;){const t=n+(o-n>>1);if(r<e[t])o=t-1;else if(r>=e[t+1])n=t+1;else{n=t;break}}return n},"binarySearch"),m=s(r=>r.split(/\n|\r(?!\n)/).reduce((e,n)=>(e.push(e.at(-1)+n.length+1),e),[0]),"getLineStartIndexes"),p=s((r,e,n)=>{const o=n?.skipChecks??!1;if(!o&&(!Array.isArray(r)&&typeof r!="string"||(typeof r=="string"||Array.isArray(r))&&r.length===0))return{column:0,line:0};if(!o&&(typeof e!="number"||typeof r=="string"&&e>=r.length||Array.isArray(r)&&e+1>=r.at(-1)))return{column:0,line:0};if(typeof r=="string"){const i=m(r),a=u(e,i);return{column:e-i[a]+1,line:a+1}}const t=u(e,r);return{column:e-r[t]+1,line:t+1}},"indexToLineColumn"),g=p;export{h as CODE_FRAME_POINTER,b as VisulimaError,x as codeFrame,C as getErrorCauses,g as indexToLineColumn,k as isVisulimaError,S as parseStacktrace,v as renderError,L as serializeError};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";var k=Object.defineProperty;var c=(e,t)=>k(e,"name",{value:t,configurable:!0});const C=require("node:util"),g=require("node:fs"),P=require("node:path"),T=require("node:process"),A=require("node:url"),I=require("../code-frame/index.cjs"),E=require("../stacktrace/index.cjs");var L=Object.defineProperty,_=c((e,t)=>L(e,"name",{value:t,configurable:!0}),"a");const F=_(e=>{const t=new Set,r=[];let o=e;for(;o;){if(t.has(o)){console.error(`Circular reference detected in error causes: ${C.inspect(e)}`);break}if(r.push(o),t.add(o),!o.cause)break;o=o.cause}return r},"getErrorCauses"),J=F;var M=Object.defineProperty,a=c((e,t)=>M(e,"name",{value:t,configurable:!0}),"o");const u=a((e,t)=>t===0?"":e===" "?" ".repeat(t):" ".repeat(e*t),"getPrefix"),$=a((e,t)=>{const r=e.replace("async file:","file:");return P.relative(t,r.startsWith("file:")?A.fileURLToPath(r):r)},"getRelativePath"),y=a((e,{color:t,hideErrorTitle:r,indentation:o},i)=>u(o,i)+(r?t.title(e.message):t.title(e.name+": "+e.message))+`
|
|
2
|
+
`,"getMessage"),v=a((e,{color:t,indentation:r},o)=>{if(e.hint===void 0)return;const i=u(r,o);let n="";if(Array.isArray(e.hint))for(const s of e.hint)n+=i+s+`
|
|
3
|
+
`;else n+=i+e.hint;return t.hint(n)},"getHint"),b=a((e,{color:t,cwd:r,displayShortPath:o,indentation:i},n=0)=>{const s=o?$(e.file,r):e.file,{fileLine:l,method:h}=t;return u(i,n)+"at "+(e.methodName?h(e.methodName)+" ":"")+l(s)+":"+l(e.line+"")},"getMainFrame"),w=a((e,{color:t,indentation:r,linesAbove:o,linesBelow:i,showGutter:n,showLineNumbers:s,tabWidth:l},h)=>{if(e.file===void 0)return;const p=e.file.replace("file://","");if(!g.existsSync(p))return;const V=g.readFileSync(p,"utf8");return I.codeFrame(V,{start:{column:e.column,line:e.line}},{color:t,linesAbove:o,linesBelow:i,prefix:u(r,h),showGutter:n,showLineNumbers:s,tabWidth:l})},"getCode"),S=a((e,t,r)=>{if(e.errors.length===0)return;let o=u(t.indentation,r)+`Errors:
|
|
4
|
+
|
|
5
|
+
`,i=!0;for(const n of e.errors)i?i=!1:o+=`
|
|
6
|
+
|
|
7
|
+
`,o+=N(n,{...t,framesMaxLimit:0,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
|
|
8
|
+
`+o},"getErrors"),O=a((e,t,r)=>{let o=u(t.indentation,r)+`Caused by:
|
|
9
|
+
|
|
10
|
+
`;const i=e.cause;o+=y(i,t,r);const n=E.parseStacktrace(i).shift(),s=v(i,t,r);return s&&(o+=s+`
|
|
11
|
+
`),o+=b(n,t,r),t.hideErrorCauseCodeView||(o+=`
|
|
12
|
+
`+w(n,t,r)),i.cause?o+=`
|
|
13
|
+
`+O(i,t,r+1):i instanceof AggregateError&&(o+=`
|
|
14
|
+
`+S(i,t,r)),`
|
|
15
|
+
`+o},"getCause"),q=a((e,t)=>{const r=e.slice(0,t.framesMaxLimit);return(r.length>0?`
|
|
16
|
+
`:"")+r.map(o=>b(o,t)).join(`
|
|
17
|
+
`)},"getStacktrace"),N=a((e,t,r)=>{const o={cwd:T.cwd(),displayShortPath:!1,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:a(s=>s,"fileLine"),gutter:a(s=>s,"gutter"),hint:a(s=>s,"hint"),marker:a(s=>s,"marker"),message:a(s=>s,"message"),method:a(s=>s,"method"),title:a(s=>s,"title"),...t.color}},i=E.parseStacktrace(e),n=i.shift();return[t.hideMessage?void 0:y(e,o,r),"",v(e,o,r),"",n?b(n,o,r):void 0,n&&!o.hideErrorCodeView?w(n,o,r):void 0,e instanceof AggregateError?S(e,o,r):void 0,e.cause===void 0?void 0:O(e,o,r),i.length>0?q(i,o):void 0].filter(Boolean).join(`
|
|
18
|
+
`)},"internalRenderError"),B=a((e,t={})=>N(e,t,0),"renderError");function D(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}c(D,"isPlainObject");const z=Object.create({},{cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},stack:{enumerable:!0,value:void 0,writable:!0}});var W=Object.defineProperty,d=c((e,t)=>W(e,"name",{value:t,configurable:!0}),"c");const m=new WeakSet,G=d(e=>{m.add(e);const t=e.toJSON();return m.delete(e),t},"toJSON"),j=d((e,t,r,o)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.includes(e)?"[Circular]":(r+=1,f(e,o,t,r));if(o.useToJSON&&typeof e.toJSON=="function")return e.toJSON();if(typeof e=="object"&&e instanceof Date)return e.toISOString();if(typeof e=="function")return"[Function: "+(e.name||"anonymous")+"]";if(D(e)){if(r+=1,o.maxDepth&&r>=o.maxDepth)return{};const i={};for(const n in e)i[n]=j(e[n],t,r,o);return i}try{return e}catch{return"[Not Available]"}},"serializeValue"),f=d((e,t,r,o)=>{if(r.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!m.has(e))return G(e);const i=Object.create(z);if(i.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,i.message=e.message,i.stack=e.stack,Array.isArray(e.errors)){const n=[];for(const s of e.errors){if(!(s instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.includes(s))return i.errors=[],i;n.push(f(s,t,r,o))}i.errors=n}e.cause instanceof Error&&!r.includes(e.cause)&&(i.cause=f(e.cause,t,r,o));for(const n in e)if(i[n]===void 0){const s=e[n];i[n]=j(s,r,o,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const n of t.exclude)try{delete i[n]}catch{}return i},"_serialize"),R=d((e,t={})=>f(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var H=Object.defineProperty,x=c((e,t)=>H(e,"name",{value:t,configurable:!0}),"t");const U=x(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class Y extends Error{static{c(this,"VisulimaError")}static{x(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:t,hint:r,location:o,message:i,name:n,stack:s,title:l}){super(i,{cause:t}),this.title=l,this.name=n,this.stack=s??this.stack,this.loc=o,this.hint=r,Error.captureStackTrace(this,this.constructor)}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}exports.VisulimaError=Y;exports.i=J;exports.isVisulimaError=U;exports.renderError=B;exports.serialize=R;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var V=Object.defineProperty;var c=(e,t)=>V(e,"name",{value:t,configurable:!0});import{inspect as C}from"node:util";import{existsSync as P,readFileSync as T}from"node:fs";import{relative as k}from"node:path";import{cwd as A}from"node:process";import{fileURLToPath as I}from"node:url";import{codeFrame as L}from"../code-frame/index.mjs";import{parseStacktrace as g}from"../stacktrace/index.mjs";var J=Object.defineProperty,$=c((e,t)=>J(e,"name",{value:t,configurable:!0}),"a");const F=$(e=>{const t=new Set,r=[];let o=e;for(;o;){if(t.has(o)){console.error(`Circular reference detected in error causes: ${C(e)}`);break}if(r.push(o),t.add(o),!o.cause)break;o=o.cause}return r},"getErrorCauses"),ee=F;var M=Object.defineProperty,a=c((e,t)=>M(e,"name",{value:t,configurable:!0}),"o");const u=a((e,t)=>t===0?"":e===" "?" ".repeat(t):" ".repeat(e*t),"getPrefix"),B=a((e,t)=>{const r=e.replace("async file:","file:");return k(t,r.startsWith("file:")?I(r):r)},"getRelativePath"),y=a((e,{color:t,hideErrorTitle:r,indentation:o},i)=>u(o,i)+(r?t.title(e.message):t.title(e.name+": "+e.message))+`
|
|
2
|
+
`,"getMessage"),E=a((e,{color:t,indentation:r},o)=>{if(e.hint===void 0)return;const i=u(r,o);let n="";if(Array.isArray(e.hint))for(const s of e.hint)n+=i+s+`
|
|
3
|
+
`;else n+=i+e.hint;return t.hint(n)},"getHint"),p=a((e,{color:t,cwd:r,displayShortPath:o,indentation:i},n=0)=>{const s=o?B(e.file,r):e.file,{fileLine:l,method:d}=t;return u(i,n)+"at "+(e.methodName?d(e.methodName)+" ":"")+l(s)+":"+l(e.line+"")},"getMainFrame"),v=a((e,{color:t,indentation:r,linesAbove:o,linesBelow:i,showGutter:n,showLineNumbers:s,tabWidth:l},d)=>{if(e.file===void 0)return;const b=e.file.replace("file://","");if(!P(b))return;const x=T(b,"utf8");return L(x,{start:{column:e.column,line:e.line}},{color:t,linesAbove:o,linesBelow:i,prefix:u(r,d),showGutter:n,showLineNumbers:s,tabWidth:l})},"getCode"),w=a((e,t,r)=>{if(e.errors.length===0)return;let o=u(t.indentation,r)+`Errors:
|
|
4
|
+
|
|
5
|
+
`,i=!0;for(const n of e.errors)i?i=!1:o+=`
|
|
6
|
+
|
|
7
|
+
`,o+=O(n,{...t,framesMaxLimit:0,hideErrorCodeView:t.hideErrorErrorsCodeView},r+1);return`
|
|
8
|
+
`+o},"getErrors"),S=a((e,t,r)=>{let o=u(t.indentation,r)+`Caused by:
|
|
9
|
+
|
|
10
|
+
`;const i=e.cause;o+=y(i,t,r);const n=g(i).shift(),s=E(i,t,r);return s&&(o+=s+`
|
|
11
|
+
`),o+=p(n,t,r),t.hideErrorCauseCodeView||(o+=`
|
|
12
|
+
`+v(n,t,r)),i.cause?o+=`
|
|
13
|
+
`+S(i,t,r+1):i instanceof AggregateError&&(o+=`
|
|
14
|
+
`+w(i,t,r)),`
|
|
15
|
+
`+o},"getCause"),D=a((e,t)=>{const r=e.slice(0,t.framesMaxLimit);return(r.length>0?`
|
|
16
|
+
`:"")+r.map(o=>p(o,t)).join(`
|
|
17
|
+
`)},"getStacktrace"),O=a((e,t,r)=>{const o={cwd:A(),displayShortPath:!1,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,showGutter:!0,showLineNumbers:!0,tabWidth:4,...t,color:{fileLine:a(s=>s,"fileLine"),gutter:a(s=>s,"gutter"),hint:a(s=>s,"hint"),marker:a(s=>s,"marker"),message:a(s=>s,"message"),method:a(s=>s,"method"),title:a(s=>s,"title"),...t.color}},i=g(e),n=i.shift();return[t.hideMessage?void 0:y(e,o,r),"",E(e,o,r),"",n?p(n,o,r):void 0,n&&!o.hideErrorCodeView?v(n,o,r):void 0,e instanceof AggregateError?w(e,o,r):void 0,e.cause===void 0?void 0:S(e,o,r),i.length>0?D(i,o):void 0].filter(Boolean).join(`
|
|
18
|
+
`)},"internalRenderError"),te=a((e,t={})=>O(e,t,0),"renderError");function W(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}c(W,"isPlainObject");const z=Object.create({},{cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},stack:{enumerable:!0,value:void 0,writable:!0}});var G=Object.defineProperty,m=c((e,t)=>G(e,"name",{value:t,configurable:!0}),"c");const h=new WeakSet,R=m(e=>{h.add(e);const t=e.toJSON();return h.delete(e),t},"toJSON"),N=m((e,t,r,o)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.includes(e)?"[Circular]":(r+=1,f(e,o,t,r));if(o.useToJSON&&typeof e.toJSON=="function")return e.toJSON();if(typeof e=="object"&&e instanceof Date)return e.toISOString();if(typeof e=="function")return"[Function: "+(e.name||"anonymous")+"]";if(W(e)){if(r+=1,o.maxDepth&&r>=o.maxDepth)return{};const i={};for(const n in e)i[n]=N(e[n],t,r,o);return i}try{return e}catch{return"[Not Available]"}},"serializeValue"),f=m((e,t,r,o)=>{if(r.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!h.has(e))return R(e);const i=Object.create(z);if(i.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,i.message=e.message,i.stack=e.stack,Array.isArray(e.errors)){const n=[];for(const s of e.errors){if(!(s instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.includes(s))return i.errors=[],i;n.push(f(s,t,r,o))}i.errors=n}e.cause instanceof Error&&!r.includes(e.cause)&&(i.cause=f(e.cause,t,r,o));for(const n in e)if(i[n]===void 0){const s=e[n];i[n]=N(s,r,o,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const n of t.exclude)try{delete i[n]}catch{}return i},"_serialize"),re=m((e,t={})=>f(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var _=Object.defineProperty,j=c((e,t)=>_(e,"name",{value:t,configurable:!0}),"t");const oe=j(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class ie extends Error{static{c(this,"VisulimaError")}static{j(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:t,hint:r,location:o,message:i,name:n,stack:s,title:l}){super(i,{cause:t}),this.title=l,this.name=n,this.stack=s??this.stack,this.loc=o,this.hint=r,Error.captureStackTrace(this,this.constructor)}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}export{ie as V,oe as a,ee as i,te as r,re as s};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type CodeFrameLocation = {
|
|
2
|
+
column?: number;
|
|
3
|
+
line: number;
|
|
4
|
+
};
|
|
5
|
+
type CodeFrameNodeLocation = {
|
|
6
|
+
end?: CodeFrameLocation;
|
|
7
|
+
start: CodeFrameLocation;
|
|
8
|
+
};
|
|
9
|
+
type ColorizeMethod = (value: string) => string;
|
|
10
|
+
type CodeFrameOptions = {
|
|
11
|
+
color?: {
|
|
12
|
+
gutter?: ColorizeMethod;
|
|
13
|
+
marker?: ColorizeMethod;
|
|
14
|
+
message?: ColorizeMethod;
|
|
15
|
+
};
|
|
16
|
+
linesAbove?: number;
|
|
17
|
+
linesBelow?: number;
|
|
18
|
+
message?: string;
|
|
19
|
+
prefix?: string;
|
|
20
|
+
showGutter?: boolean;
|
|
21
|
+
showLineNumbers?: boolean;
|
|
22
|
+
tabWidth?: number | false;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type { CodeFrameLocation as C, CodeFrameNodeLocation as a, CodeFrameOptions as b, ColorizeMethod as c };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type CodeFrameLocation = {
|
|
2
|
+
column?: number;
|
|
3
|
+
line: number;
|
|
4
|
+
};
|
|
5
|
+
type CodeFrameNodeLocation = {
|
|
6
|
+
end?: CodeFrameLocation;
|
|
7
|
+
start: CodeFrameLocation;
|
|
8
|
+
};
|
|
9
|
+
type ColorizeMethod = (value: string) => string;
|
|
10
|
+
type CodeFrameOptions = {
|
|
11
|
+
color?: {
|
|
12
|
+
gutter?: ColorizeMethod;
|
|
13
|
+
marker?: ColorizeMethod;
|
|
14
|
+
message?: ColorizeMethod;
|
|
15
|
+
};
|
|
16
|
+
linesAbove?: number;
|
|
17
|
+
linesBelow?: number;
|
|
18
|
+
message?: string;
|
|
19
|
+
prefix?: string;
|
|
20
|
+
showGutter?: boolean;
|
|
21
|
+
showLineNumbers?: boolean;
|
|
22
|
+
tabWidth?: number | false;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type { CodeFrameLocation as C, CodeFrameNodeLocation as a, CodeFrameOptions as b, ColorizeMethod as c };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type CodeFrameLocation = {
|
|
2
|
+
column?: number;
|
|
3
|
+
line: number;
|
|
4
|
+
};
|
|
5
|
+
type CodeFrameNodeLocation = {
|
|
6
|
+
end?: CodeFrameLocation;
|
|
7
|
+
start: CodeFrameLocation;
|
|
8
|
+
};
|
|
9
|
+
type ColorizeMethod = (value: string) => string;
|
|
10
|
+
type CodeFrameOptions = {
|
|
11
|
+
color?: {
|
|
12
|
+
gutter?: ColorizeMethod;
|
|
13
|
+
marker?: ColorizeMethod;
|
|
14
|
+
message?: ColorizeMethod;
|
|
15
|
+
};
|
|
16
|
+
linesAbove?: number;
|
|
17
|
+
linesBelow?: number;
|
|
18
|
+
message?: string;
|
|
19
|
+
prefix?: string;
|
|
20
|
+
showGutter?: boolean;
|
|
21
|
+
showLineNumbers?: boolean;
|
|
22
|
+
tabWidth?: number | false;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type { CodeFrameLocation as C, CodeFrameNodeLocation as a, CodeFrameOptions as b, ColorizeMethod as c };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/error",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Error with more than just a message, stacktrace parsing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -25,6 +25,17 @@
|
|
|
25
25
|
"text",
|
|
26
26
|
"trace",
|
|
27
27
|
"v8",
|
|
28
|
+
"source",
|
|
29
|
+
"code",
|
|
30
|
+
"frame",
|
|
31
|
+
"stack",
|
|
32
|
+
"callstack",
|
|
33
|
+
"call",
|
|
34
|
+
"source-code",
|
|
35
|
+
"pretty-error",
|
|
36
|
+
"pretty-exceptions",
|
|
37
|
+
"exception",
|
|
38
|
+
"pretty",
|
|
28
39
|
"visulima"
|
|
29
40
|
],
|
|
30
41
|
"homepage": "https://www.visulima.com/docs/package/error",
|
|
@@ -118,23 +129,23 @@
|
|
|
118
129
|
"@types/command-line-args": "^5.2.3",
|
|
119
130
|
"@types/node": "18.19.15",
|
|
120
131
|
"@visulima/nextra-theme-docs": "4.0.26",
|
|
132
|
+
"@visulima/packem": "^1.0.0-alpha.46",
|
|
121
133
|
"@visulima/path": "1.0.2",
|
|
122
134
|
"@vitest/coverage-v8": "^1.6.0",
|
|
123
135
|
"@vitest/ui": "^1.6.0",
|
|
124
136
|
"conventional-changelog-conventionalcommits": "8.0.0",
|
|
125
137
|
"cross-env": "^7.0.3",
|
|
138
|
+
"esbuild": "0.22.0",
|
|
126
139
|
"eslint": "^8.57.0",
|
|
127
140
|
"eslint-plugin-deprecation": "^3.0.0",
|
|
128
141
|
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
129
142
|
"eslint-plugin-mdx": "^3.1.5",
|
|
130
|
-
"is-plain-obj": "^4.1.0",
|
|
131
143
|
"eslint-plugin-vitest": "^0.4.1",
|
|
132
144
|
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
145
|
+
"is-plain-obj": "^4.1.0",
|
|
133
146
|
"prettier": "^3.3.2",
|
|
134
147
|
"rimraf": "^5.0.7",
|
|
135
148
|
"semantic-release": "24.0.0",
|
|
136
|
-
"@visulima/packem": "^1.0.0-alpha.46",
|
|
137
|
-
"esbuild": "^0.21.5",
|
|
138
149
|
"typescript": "^5.4.5",
|
|
139
150
|
"vitest": "^1.6.0"
|
|
140
151
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var h=Object.defineProperty;var a=(e,t)=>h(e,"name",{value:t,configurable:!0});import{inspect as y}from"node:util";var d=Object.defineProperty,O=a((e,t)=>d(e,"name",{value:t,configurable:!0}),"a");const S=O(e=>{const t=new Set,o=[];let r=e;for(;r;){if(t.has(r)){console.error(`Circular reference detected in error causes: ${y(e)}`);break}if(o.push(r),t.add(r),!r.cause)break;r=r.cause}return o},"getErrorCauses"),w=S;function g(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}a(g,"isPlainObject");const v=Object.create({},{cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},stack:{enumerable:!0,value:void 0,writable:!0}});var E=Object.defineProperty,u=a((e,t)=>E(e,"name",{value:t,configurable:!0}),"c");const l=new WeakSet,j=u(e=>{l.add(e);const t=e.toJSON();return l.delete(e),t},"toJSON"),f=u((e,t,o,r)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.includes(e)?"[Circular]":(o+=1,c(e,r,t,o));if(r.useToJSON&&typeof e.toJSON=="function")return e.toJSON();if(typeof e=="object"&&e instanceof Date)return e.toISOString();if(typeof e=="function")return"[Function: "+(e.name||"anonymous")+"]";if(g(e)){if(o+=1,r.maxDepth&&o>=r.maxDepth)return{};const n={};for(const s in e)n[s]=f(e[s],t,o,r);return n}try{return e}catch{return"[Not Available]"}},"serializeValue"),c=u((e,t,o,r)=>{if(o.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!l.has(e))return j(e);const n=Object.create(v);if(n.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,n.message=e.message,n.stack=e.stack,Array.isArray(e.errors)){const s=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(o.includes(i))return n.errors=[],n;s.push(c(i,t,o,r))}n.errors=s}e.cause instanceof Error&&!o.includes(e.cause)&&(n.cause=c(e.cause,t,o,r));for(const s in e)if(n[s]===void 0){const i=e[s];n[s]=f(i,o,r,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const s of t.exclude)try{delete n[s]}catch{}return n},"_serialize"),J=u((e,t={})=>c(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var N=Object.defineProperty,m=a((e,t)=>N(e,"name",{value:t,configurable:!0}),"t");const T=m(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class V extends Error{static{a(this,"VisulimaError")}static{m(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor(t,...o){super(...o);const{hint:r,location:n,message:s,name:i,stack:b,title:p}=t;this.title=p,this.name=i,s&&(this.message=s),this.stack=b??this.stack,this.loc=n,this.hint=r,Error.captureStackTrace(this,this.constructor)}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}export{V,T as a,w as i,J as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var a=(e,t)=>h(e,"name",{value:t,configurable:!0});const d=require("node:util");var y=Object.defineProperty,O=a((e,t)=>y(e,"name",{value:t,configurable:!0}),"a");const E=O(e=>{const t=new Set,o=[];let r=e;for(;r;){if(t.has(r)){console.error(`Circular reference detected in error causes: ${d.inspect(e)}`);break}if(o.push(r),t.add(r),!r.cause)break;r=r.cause}return o},"getErrorCauses"),S=E;function g(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}a(g,"isPlainObject");const v=Object.create({},{cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},stack:{enumerable:!0,value:void 0,writable:!0}});var j=Object.defineProperty,u=a((e,t)=>j(e,"name",{value:t,configurable:!0}),"c");const l=new WeakSet,N=u(e=>{l.add(e);const t=e.toJSON();return l.delete(e),t},"toJSON"),f=u((e,t,o,r)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.includes(e)?"[Circular]":(o+=1,c(e,r,t,o));if(r.useToJSON&&typeof e.toJSON=="function")return e.toJSON();if(typeof e=="object"&&e instanceof Date)return e.toISOString();if(typeof e=="function")return"[Function: "+(e.name||"anonymous")+"]";if(g(e)){if(o+=1,r.maxDepth&&o>=r.maxDepth)return{};const n={};for(const s in e)n[s]=f(e[s],t,o,r);return n}try{return e}catch{return"[Not Available]"}},"serializeValue"),c=u((e,t,o,r)=>{if(o.push(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!l.has(e))return N(e);const n=Object.create(v);if(n.name=Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,n.message=e.message,n.stack=e.stack,Array.isArray(e.errors)){const s=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(o.includes(i))return n.errors=[],n;s.push(c(i,t,o,r))}n.errors=s}e.cause instanceof Error&&!o.includes(e.cause)&&(n.cause=c(e.cause,t,o,r));for(const s in e)if(n[s]===void 0){const i=e[s];n[s]=f(i,o,r,t)}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const s of t.exclude)try{delete n[s]}catch{}return n},"_serialize"),x=u((e,t={})=>c(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},[],0),"serialize");var k=Object.defineProperty,m=a((e,t)=>k(e,"name",{value:t,configurable:!0}),"t");const w=m(e=>e instanceof Error&&e.type==="VisulimaError","isVisulimaError");class V extends Error{static{a(this,"VisulimaError")}static{m(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor(t,...o){super(...o);const{hint:r,location:n,message:s,name:i,stack:b,title:p}=t;this.title=p,this.name=i,s&&(this.message=s),this.stack=b??this.stack,this.loc=n,this.hint=r,Error.captureStackTrace(this,this.constructor)}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}}exports.VisulimaError=V;exports.i=S;exports.isVisulimaError=w;exports.serialize=x;
|