@visulima/error 3.0.0 → 3.0.1
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 +7 -0
- package/dist/chunk-YOONH3EZ.js +8 -0
- package/dist/chunk-YOONH3EZ.js.map +1 -0
- package/dist/error/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-HO52DUB2.js +0 -7
- package/dist/chunk-HO52DUB2.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## @visulima/error [3.0.1](https://github.com/visulima/visulima/compare/@visulima/error@3.0.0...@visulima/error@3.0.1) (2023-12-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fixed possible deep nesting of error cause in getErrorCauses ([350ddba](https://github.com/visulima/visulima/commit/350ddbaf2b8120a0815f1673fc1582ca7946847d))
|
|
7
|
+
|
|
1
8
|
## @visulima/error [3.0.0](https://github.com/visulima/visulima/compare/@visulima/error@2.0.0...@visulima/error@3.0.0) (2023-12-06)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { a } from './chunk-GQSCBKA6.js';
|
|
2
|
+
import { inspect } from 'util';
|
|
3
|
+
|
|
4
|
+
var d=i=>{let s=new Set,r=[],t=i;for(;t;){if(s.has(t)){console.error(`Circular reference detected in error causes: ${inspect(i)}`);break}if(r.push(t),s.add(t),!t.cause)break;t=t.cause;}return r},f=d;var b=i=>i instanceof Error&&i.type==="VisulimaError",o=class extends Error{constructor(r,...t){super(...t);a(this,"loc");a(this,"title");a(this,"hint");a(this,"type","VisulimaError");let{hint:u,location:l,message:n,name:p,stack:E,title:m}=r;this.title=m,this.name=p,n&&(this.message=n),this.stack=E??this.stack,this.loc=l,this.hint=u,Error.captureStackTrace(this,this.constructor);}setLocation(r){this.loc=r;}setName(r){this.name=r;}setMessage(r){this.message=r;}setHint(r){this.hint=r;}};
|
|
5
|
+
|
|
6
|
+
export { f as a, b, o as c };
|
|
7
|
+
//# sourceMappingURL=out.js.map
|
|
8
|
+
//# sourceMappingURL=chunk-YOONH3EZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/get-error-causes.ts","../src/error/visulima-error.ts"],"names":["inspect","getErrorCauses","error","seen","causes","currentError","get_error_causes_default","isVisulimaError","VisulimaError","properties","parameters","__publicField","hint","location","message","name","stack","title"],"mappings":"wCAAA,OAAS,WAAAA,MAAe,OAQxB,IAAMC,EAAuDC,GAAkB,CAC3E,IAAMC,EAAO,IAAI,IACXC,EAAS,CAAC,EAGZC,EAAwBH,EAG5B,KAAOG,GAAc,CAEjB,GAAIF,EAAK,IAAIE,CAAY,EAAG,CAExB,QAAQ,MAAM,gDAAgDL,EAAQE,CAAK,CAAC,EAAE,EAE9E,KACJ,CAKA,GAHAE,EAAO,KAAKC,CAAY,EACxBF,EAAK,IAAIE,CAAY,EAEjB,CAACA,EAAa,MACd,MAGJA,EAAeA,EAAa,KAChC,CAEA,OAAOD,CACX,EAEOE,EAAQL,ECpCR,IAAMM,EAAmBL,GAA2CA,aAAiB,OAAUA,EAAwB,OAAS,gBAE1HM,EAAN,cAA4B,KAAM,CAa9B,YAAYC,KAAgCC,EAAiB,CAEhE,MAAM,GAAGA,CAAU,EAdvBC,EAAA,KAAO,OAEPA,EAAA,KAAO,SAKPA,EAAA,KAAO,QAEPA,EAAA,KAAO,OAAO,iBAOV,GAAM,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,KAAAC,EAAM,MAAAC,EAAO,MAAAC,CAAM,EAAIR,EACxD,KAAK,MAAQQ,EACb,KAAK,KAAOF,EAERD,IACA,KAAK,QAAUA,GAInB,KAAK,MAAQE,GAAU,KAAK,MAC5B,KAAK,IAAMH,EACX,KAAK,KAAOD,EAEZ,MAAM,kBAAkB,KAAM,KAAK,WAAW,CAClD,CAEO,YAAYC,EAA+B,CAC9C,KAAK,IAAMA,CACf,CAEO,QAAQE,EAAoB,CAC/B,KAAK,KAAOA,CAChB,CAEO,WAAWD,EAAuB,CACrC,KAAK,QAAUA,CACnB,CAEO,QAAQF,EAAuB,CAClC,KAAK,KAAOA,CAChB,CACJ","sourcesContent":["import { inspect } from \"node:util\";\n\nimport type { VisulimaError } from \"./visulima-error\";\n\n/**\n * Will return an array of all causes in the error in the order they occurred.\n */\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nconst getErrorCauses = <E = Error | VisulimaError | unknown>(error: E): E[] => {\n const seen = new Set();\n const causes = [];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-redundant-type-constituents\n let currentError: E | any = error;\n\n // eslint-disable-next-line no-loops/no-loops\n while (currentError) {\n // Check for circular reference\n if (seen.has(currentError)) {\n // eslint-disable-next-line no-console\n console.error(`Circular reference detected in error causes: ${inspect(error)}`);\n\n break;\n }\n\n causes.push(currentError);\n seen.add(currentError);\n\n if (!currentError.cause) {\n break;\n }\n\n currentError = currentError.cause;\n }\n\n return causes as E[];\n};\n\nexport default getErrorCauses;\n","import type { ErrorHint, ErrorLocation, ErrorProperties } from \"./types\";\n\nexport const isVisulimaError = (error: unknown): error is VisulimaError => error instanceof Error && (error as VisulimaError).type === \"VisulimaError\";\n\nexport class VisulimaError extends Error {\n public loc: ErrorLocation | undefined;\n\n public title: string | undefined;\n\n /**\n * A message that explains to the user how they can fix the error.\n */\n public hint: ErrorHint | undefined;\n\n public type = \"VisulimaError\";\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\n public constructor(properties: ErrorProperties, ...parameters: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n super(...parameters);\n\n const { hint, location, message, name, stack, title } = properties;\n this.title = title;\n this.name = name;\n\n if (message) {\n this.message = message;\n }\n\n // Only set this if we actually have a stack passed, otherwise uses Error's\n this.stack = stack ?? (this.stack as string);\n this.loc = location;\n this.hint = hint;\n\n Error.captureStackTrace(this, this.constructor);\n }\n\n public setLocation(location: ErrorLocation): void {\n this.loc = location;\n }\n\n public setName(name: string): void {\n this.name = name;\n }\n\n public setMessage(message: string): void {\n this.message = message;\n }\n\n public setHint(hint: ErrorHint): void {\n this.hint = hint;\n }\n}\n"]}
|
package/dist/error/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as VisulimaError, a as getErrorCauses, b as isVisulimaError } from '../chunk-
|
|
1
|
+
export { c as VisulimaError, a as getErrorCauses, b as isVisulimaError } from '../chunk-YOONH3EZ.js';
|
|
2
2
|
import '../chunk-GQSCBKA6.js';
|
|
3
3
|
//# sourceMappingURL=out.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { a as codeFrame } from './chunk-7OT5SHJH.js';
|
|
2
|
-
export { c as VisulimaError, a as getErrorCauses, b as isVisulimaError } from './chunk-
|
|
2
|
+
export { c as VisulimaError, a as getErrorCauses, b as isVisulimaError } from './chunk-YOONH3EZ.js';
|
|
3
3
|
export { b as generatedPositionFor, a as loadSourceMap, c as originalPositionFor, d as sourceContentFor, e as traceSegment } from './chunk-ONFIDS3C.js';
|
|
4
4
|
export { a as parseStacktrace } from './chunk-57YC2IM6.js';
|
|
5
5
|
import './chunk-GQSCBKA6.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/error",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Error with more than just a message, stacktrace parsing and sourcemap loading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"eslint-plugin-vitest-globals": "^1.4.0",
|
|
126
126
|
"prettier": "^3.1.0",
|
|
127
127
|
"rimraf": "^5.0.5",
|
|
128
|
-
"semantic-release": "^22.0.
|
|
128
|
+
"semantic-release": "^22.0.10",
|
|
129
129
|
"sort-package-json": "^2.6.0",
|
|
130
130
|
"tsup": "^8.0.1",
|
|
131
131
|
"typescript": "^5.3.2",
|
package/dist/chunk-HO52DUB2.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-GQSCBKA6.js';
|
|
2
|
-
|
|
3
|
-
var h=t=>{let o=[],r=t;for(;r&&(o.push(r),!!r.cause);)r=r.cause;return o},d=h;var f=t=>t instanceof Error&&t.type==="VisulimaError",s=class extends Error{constructor(r,...c){super(...c);a(this,"loc");a(this,"title");a(this,"hint");a(this,"type","VisulimaError");let{hint:u,location:E,message:e,name:l,stack:p,title:m}=r;this.title=m,this.name=l,e&&(this.message=e),this.stack=p??this.stack,this.loc=E,this.hint=u,Error.captureStackTrace(this,this.constructor);}setLocation(r){this.loc=r;}setName(r){this.name=r;}setMessage(r){this.message=r;}setHint(r){this.hint=r;}};
|
|
4
|
-
|
|
5
|
-
export { d as a, f as b, s as c };
|
|
6
|
-
//# sourceMappingURL=out.js.map
|
|
7
|
-
//# sourceMappingURL=chunk-HO52DUB2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error/get-error-causes.ts","../src/error/visulima-error.ts"],"names":["getErrorCauses","error","causes","currentError","get_error_causes_default","isVisulimaError","VisulimaError","properties","parameters","__publicField","hint","location","message","name","stack","title"],"mappings":"wCAMA,IAAMA,EAAuDC,GAAkB,CAC3E,IAAMC,EAAS,CAAC,EAGZC,EAAwBF,EAG5B,KAAOE,IACHD,EAAO,KAAKC,CAAY,EAEpB,EAACA,EAAa,QAIlBA,EAAeA,EAAa,MAGhC,OAAOD,CACX,EAEOE,EAAQJ,ECxBR,IAAMK,EAAmBJ,GAA2CA,aAAiB,OAAUA,EAAwB,OAAS,gBAE1HK,EAAN,cAA4B,KAAM,CAa9B,YAAYC,KAAgCC,EAAiB,CAEhE,MAAM,GAAGA,CAAU,EAdvBC,EAAA,KAAO,OAEPA,EAAA,KAAO,SAKPA,EAAA,KAAO,QAEPA,EAAA,KAAO,OAAO,iBAOV,GAAM,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAS,KAAAC,EAAM,MAAAC,EAAO,MAAAC,CAAM,EAAIR,EACxD,KAAK,MAAQQ,EACb,KAAK,KAAOF,EAERD,IACA,KAAK,QAAUA,GAInB,KAAK,MAAQE,GAAU,KAAK,MAC5B,KAAK,IAAMH,EACX,KAAK,KAAOD,EAEZ,MAAM,kBAAkB,KAAM,KAAK,WAAW,CAClD,CAEO,YAAYC,EAA+B,CAC9C,KAAK,IAAMA,CACf,CAEO,QAAQE,EAAoB,CAC/B,KAAK,KAAOA,CAChB,CAEO,WAAWD,EAAuB,CACrC,KAAK,QAAUA,CACnB,CAEO,QAAQF,EAAuB,CAClC,KAAK,KAAOA,CAChB,CACJ","sourcesContent":["import type { VisulimaError } from \"./visulima-error\";\n\n/**\n * Will return an array of all causes in the error in the order they occurred.\n */\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nconst getErrorCauses = <E = Error | VisulimaError | unknown>(error: E): E[] => {\n const causes = [];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-redundant-type-constituents\n let currentError: E | any = error;\n\n // eslint-disable-next-line no-loops/no-loops\n while (currentError) {\n causes.push(currentError);\n\n if (!currentError.cause) {\n break;\n }\n\n currentError = currentError.cause;\n }\n\n return causes as E[];\n};\n\nexport default getErrorCauses;\n","import type { ErrorHint, ErrorLocation, ErrorProperties } from \"./types\";\n\nexport const isVisulimaError = (error: unknown): error is VisulimaError => error instanceof Error && (error as VisulimaError).type === \"VisulimaError\";\n\nexport class VisulimaError extends Error {\n public loc: ErrorLocation | undefined;\n\n public title: string | undefined;\n\n /**\n * A message that explains to the user how they can fix the error.\n */\n public hint: ErrorHint | undefined;\n\n public type = \"VisulimaError\";\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any\n public constructor(properties: ErrorProperties, ...parameters: any) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n super(...parameters);\n\n const { hint, location, message, name, stack, title } = properties;\n this.title = title;\n this.name = name;\n\n if (message) {\n this.message = message;\n }\n\n // Only set this if we actually have a stack passed, otherwise uses Error's\n this.stack = stack ?? (this.stack as string);\n this.loc = location;\n this.hint = hint;\n\n Error.captureStackTrace(this, this.constructor);\n }\n\n public setLocation(location: ErrorLocation): void {\n this.loc = location;\n }\n\n public setName(name: string): void {\n this.name = name;\n }\n\n public setMessage(message: string): void {\n this.message = message;\n }\n\n public setHint(hint: ErrorHint): void {\n this.hint = hint;\n }\n}\n"]}
|