@simbo/user-facing-error 2.0.0 → 2.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 +9 -0
- package/README.md +1 -1
- package/dist/index.js.map +1 -1
- package/dist/user-facing-error.js +0 -1
- package/dist/user-facing-error.js.map +1 -1
- package/dist/user-facing-error.types.js.map +1 -1
- package/package.json +11 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @simbo/user-facing-error
|
|
2
2
|
|
|
3
|
+
## 2.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6f304e0: Include the original sources in source maps (`inlineSources`), so
|
|
8
|
+
debuggers and stack traces show the TypeScript code without publishing `src`.
|
|
9
|
+
- Updated dependencies [6f304e0]
|
|
10
|
+
- @simbo/stringify-error@2.0.1
|
|
11
|
+
|
|
3
12
|
## 2.0.0
|
|
4
13
|
|
|
5
14
|
### Major Changes
|
package/README.md
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './user-facing-error.js';\nexport type * from './user-facing-error.types.js';\n"]}
|
|
@@ -22,7 +22,6 @@ export class UserFacingError extends Error {
|
|
|
22
22
|
* @param options - Optional hint or ErrorOptions.
|
|
23
23
|
*/
|
|
24
24
|
constructor(message, options) {
|
|
25
|
-
// eslint-disable-next-line unicorn/custom-error-definition -- The public API also accepts a hint instead of ErrorOptions.
|
|
26
25
|
super(message, typeof options === 'object' ? options : undefined);
|
|
27
26
|
this.hint = this.#getHintValue(options);
|
|
28
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-facing-error.js","sourceRoot":"","sources":["../src/user-facing-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACf,IAAI,GAAG,iBAAiB,CAAC;IAClC,IAAI,CAAO;IAE3B;;;;;OAKG;IACH,YAAmB,OAAe,EAAE,OAAqB;QACvD,
|
|
1
|
+
{"version":3,"file":"user-facing-error.js","sourceRoot":"","sources":["../src/user-facing-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACf,IAAI,GAAG,iBAAiB,CAAC;IAClC,IAAI,CAAO;IAE3B;;;;;OAKG;IACH,YAAmB,OAAe,EAAE,OAAqB;QACvD,KAAK,CAAC,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,IAAI,CAAC,KAAc,EAAE,OAAe,EAAE,OAAqB;QACvE,MAAM,WAAW,GAAgB;YAC/B,GAAG,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAK,OAAmB,KAAK,IAAI;gBAC9D,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC;oBACE,IAAI,EAAE,OAAe;iBACtB,CAAC;YACN,KAAK,EAAE,KAAK;SACb,CAAC;QACF,OAAO,IAAI,eAAe,CAAC,GAAG,OAAO,KAAK,cAAc,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACnF,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,OAAqB;QACjC,OAAO,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ;YACpD,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ;gBACxB,OAAmB,KAAK,IAAI;gBAC7B,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC;gBAC7D,CAAC,CAAC,OAAO,CAAC,IAAI;gBACd,CAAC,CAAC,SAAS,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { stringifyError } from '@simbo/stringify-error';\n\nimport type { Hint, SecondParam } from './user-facing-error.types.js';\n\n/**\n * An error that will be displayed to the user.\n *\n * Beside the main message, it can include an additional hint message to help\n * the user resolve the issue.\n *\n * The hint option can also be `true` to indicate that a generic hint should be\n * shown. (e.g. refer to `--help`).\n *\n * This class extends the standard Error class and also accepts an ErrorOptions\n * object including the `hint` property beside other standard error properties\n * like `cause`.\n */\nexport class UserFacingError extends Error {\n public override readonly name = 'UserFacingError';\n public readonly hint: Hint;\n\n /**\n * Creates a new UserFacingError instance.\n *\n * @param message - The main error message.\n * @param options - Optional hint or ErrorOptions.\n */\n public constructor(message: string, options?: SecondParam) {\n super(message, typeof options === 'object' ? options : undefined);\n this.hint = this.#getHintValue(options);\n }\n\n /**\n * Creates a UserFacingError from another error, wrapping it with a new message.\n * It can also include a hint string or boolean.\n *\n * @param error - The original error to wrap.\n * @param message - The new message for the UserFacingError.\n * @param options - Optional hint or ErrorOptions.\n * @returns A new UserFacingError instance.\n */\n public static from(error: unknown, message: string, options?: SecondParam): UserFacingError {\n const secondParam: SecondParam = {\n ...(typeof options === 'object' && (options as unknown) !== null\n ? options\n : {\n hint: options as Hint,\n }),\n cause: error,\n };\n return new UserFacingError(`${message} (${stringifyError(error)})`, secondParam);\n }\n\n /**\n * Extracts the hint value from the options.\n *\n * @param options - The options to extract the hint from.\n * @returns The hint value or undefined.\n */\n #getHintValue(options?: SecondParam): Hint {\n return options === true || typeof options === 'string'\n ? options\n : typeof options === 'object' &&\n (options as unknown) !== null &&\n (options.hint === true || typeof options.hint === 'string')\n ? options.hint\n : undefined;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-facing-error.types.js","sourceRoot":"","sources":["../src/user-facing-error.types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"user-facing-error.types.js","sourceRoot":"","sources":["../src/user-facing-error.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The options for the UserFacingError.\n * It can include a hint string to help the user resolve the issue.\n * The hint option can also be `true` to indicate that a generic hint should be shown.\n * It extends the standard ErrorOptions.\n */\nexport interface Options extends ErrorOptions {\n hint?: string | boolean;\n}\n\n/**\n * The type for second parameter for UserFacingError.\n * It can be a string, a boolean, or an object with additional options.\n */\nexport type SecondParam = string | boolean | Options;\n\n/**\n * The type for the value of the hint in UserFacingError.\n * It can be a string, a boolean, or undefined.\n */\nexport type Hint = string | true | undefined;\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simbo/user-facing-error",
|
|
3
3
|
"description": "A custom Error class for creating user-facing error messages with an optional hint to guide users toward resolving issues.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"error",
|
|
7
7
|
"error-handling",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"author": "Simon Lepel <simbo@simbo.de> (https://simbo.de/)",
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"homepage": "
|
|
20
|
+
"homepage": "https://github.com/simbo/packages/tree/main/packages/user-facing-error",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
23
|
"url": "github:simbo/packages"
|
|
@@ -37,28 +37,23 @@
|
|
|
37
37
|
"README.md"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@simbo/stringify-error": "2.0.
|
|
40
|
+
"@simbo/stringify-error": "2.0.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"@simbo/
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"
|
|
49
|
-
"@vitest/ui": "^5.0.1",
|
|
50
|
-
"baseline-browser-mapping": "^2.11.25",
|
|
51
|
-
"eslint": "^10.11.0",
|
|
43
|
+
"@simbo/eslint-config": "3.3.0",
|
|
44
|
+
"@simbo/tsconfig": "2.1.0",
|
|
45
|
+
"@types/node": "^24.19.2",
|
|
46
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
47
|
+
"@vitest/ui": "^5.1.0",
|
|
48
|
+
"eslint": "^10.14.0",
|
|
52
49
|
"jiti": "^2.7.0",
|
|
53
|
-
"prettier": "^3.9.8",
|
|
54
50
|
"typescript": "^6.0.3",
|
|
55
|
-
"vitest": "^5.0
|
|
51
|
+
"vitest": "^5.1.0"
|
|
56
52
|
},
|
|
57
53
|
"scripts": {
|
|
58
54
|
"build": "tsc --project tsconfig.build.json",
|
|
59
|
-
"check": "pnpm run check:eslint && pnpm run check:
|
|
55
|
+
"check": "pnpm run check:eslint && pnpm run check:types",
|
|
60
56
|
"check:eslint": "eslint --config ./eslint.config.ts --max-warnings 0",
|
|
61
|
-
"check:format": "prettier --check .",
|
|
62
57
|
"check:types": "tsc --noEmit",
|
|
63
58
|
"clean": "pnpm run clean:dist && pnpm run clean:coverage && pnpm run clean:turbo && pnpm run clean:node_modules",
|
|
64
59
|
"clean:dist": "rm -rf dist",
|
|
@@ -66,7 +61,6 @@
|
|
|
66
61
|
"clean:turbo": "rm -rf .turbo",
|
|
67
62
|
"clean:coverage": "rm -rf coverage",
|
|
68
63
|
"fix:eslint": "pnpm run check:eslint --fix",
|
|
69
|
-
"fix:format": "prettier --write .",
|
|
70
64
|
"test": "vitest run --coverage",
|
|
71
65
|
"test:ui": "pnpm run test:watch --ui",
|
|
72
66
|
"test:watch": "vitest dev --coverage"
|