@thi.ng/errors 2.4.19 → 2.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-03-01T15:22:50Z
3
+ - **Last updated**: 2024-03-13T14:04:31Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [2.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/errors@2.5.0) (2024-03-13)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add CustomError interface, update docs, add tests ([d2ea8b2](https://github.com/thi-ng/umbrella/commit/d2ea8b2))
17
+
12
18
  ### [2.4.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/errors@2.4.1) (2023-11-09)
13
19
 
14
20
  #### ♻️ Refactoring
package/assert.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  export declare const AssertionError: {
3
3
  new (msg?: any): {
4
+ origMessage: string;
4
5
  name: string;
5
6
  message: string;
6
7
  stack?: string | undefined;
package/deferror.d.ts CHANGED
@@ -1,6 +1,24 @@
1
1
  /// <reference types="node" />
2
- export declare const defError: <T = string>(prefix: (msg?: T | undefined) => string, suffix?: (msg?: T | undefined) => string) => {
3
- new (msg?: T | undefined): {
2
+ export interface CustomError extends Error {
3
+ /**
4
+ * The original message given to the error ctor (prior to applying
5
+ * prefix/suffix). If none was given this will be an empty string.
6
+ */
7
+ origMessage: string;
8
+ }
9
+ /**
10
+ * Defines a custom error type/class which implements the {@link CustomError}
11
+ * interface.
12
+ *
13
+ * @remarks
14
+ * All error types in this package are defined via this function.
15
+ *
16
+ * @param prefix
17
+ * @param suffix
18
+ */
19
+ export declare const defError: <T = string>(prefix: (msg?: T) => string, suffix?: (msg?: T) => string) => {
20
+ new (msg?: T): {
21
+ origMessage: string;
4
22
  name: string;
5
23
  message: string;
6
24
  stack?: string | undefined;
package/deferror.js CHANGED
@@ -1,6 +1,8 @@
1
1
  const defError = (prefix, suffix = (msg) => msg !== void 0 ? ": " + msg : "") => class extends Error {
2
+ origMessage;
2
3
  constructor(msg) {
3
4
  super(prefix(msg) + suffix(msg));
5
+ this.origMessage = msg !== void 0 ? String(msg) : "";
4
6
  }
5
7
  };
6
8
  export {
package/ensure.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Higher-order function to define ensurance assertions. Takes a `pred`icate
2
+ * Higher-order function to define assurance assertions. Takes a `pred`icate
3
3
  * function and an `expected` (type) name, returns a new function which accepts
4
- * 2 args (an arbitrary value `x` and optional error `msg`). When called, checks
5
- * `x` for non-null and if so applies given `pred`icate. If result is false (or
6
- * `x` is nullish) and iff {@link assert} is enabled, throws a
4
+ * 2 args: an arbitrary value `x` and optional error `msg`. When called, checks
5
+ * `x` for non-nullishness and if so applies given `pred`icate. If result is
6
+ * false (or `x` is nullish) and iff {@link assert} is enabled, throws a
7
7
  * {@link AssertionError} with given `msg` (or a constructed default msg).
8
8
  * Otherwise function is a no-op.
9
9
  *
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  export declare const IllegalArgumentError: {
3
3
  new (msg?: any): {
4
+ origMessage: string;
4
5
  name: string;
5
6
  message: string;
6
7
  stack?: string | undefined;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  export declare const IllegalArityError: {
3
3
  new (msg?: number | undefined): {
4
+ origMessage: string;
4
5
  name: string;
5
6
  message: string;
6
7
  stack?: string | undefined;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  export declare const IllegalStateError: {
3
3
  new (msg?: any): {
4
+ origMessage: string;
4
5
  name: string;
5
6
  message: string;
6
7
  stack?: string | undefined;
package/io.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  export declare const IOError: {
3
3
  new (msg?: any): {
4
+ origMessage: string;
4
5
  name: string;
5
6
  message: string;
6
7
  stack?: string | undefined;
@@ -13,6 +14,7 @@ export declare const IOError: {
13
14
  export declare const ioerror: (msg?: any) => never;
14
15
  export declare const FileNotFoundError: {
15
16
  new (msg?: any): {
17
+ origMessage: string;
16
18
  name: string;
17
19
  message: string;
18
20
  stack?: string | undefined;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  export declare const OutOfBoundsError: {
3
3
  new (msg?: any): {
4
+ origMessage: string;
4
5
  name: string;
5
6
  message: string;
6
7
  stack?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/errors",
3
- "version": "2.4.19",
3
+ "version": "2.5.0",
4
4
  "description": "Custom error types and error factory functions",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -32,15 +32,16 @@
32
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
33
33
  "doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
34
34
  "pub": "yarn npm publish --access public",
35
- "test": "bun test"
35
+ "test": "bun test",
36
+ "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
36
37
  },
37
38
  "devDependencies": {
38
- "@microsoft/api-extractor": "^7.40.1",
39
- "@types/node": "^20.11.17",
40
- "esbuild": "^0.20.0",
39
+ "@microsoft/api-extractor": "^7.42.3",
40
+ "@types/node": "^20.11.26",
41
+ "esbuild": "^0.20.1",
41
42
  "rimraf": "^5.0.5",
42
- "typedoc": "^0.25.7",
43
- "typescript": "^5.3.3"
43
+ "typedoc": "^0.25.12",
44
+ "typescript": "^5.4.2"
44
45
  },
45
46
  "keywords": [
46
47
  "assert",
@@ -96,5 +97,5 @@
96
97
  "thi.ng": {
97
98
  "year": 2018
98
99
  },
99
- "gitHead": "d660ae8fd1bf64d919b4334f19509f1f539d70f6\n"
100
+ "gitHead": "7f3fcbd6c0462b0ce45afa141fe163d1f297fd51\n"
100
101
  }
package/unsupported.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  export declare const UnsupportedOperationError: {
3
3
  new (msg?: any): {
4
+ origMessage: string;
4
5
  name: string;
5
6
  message: string;
6
7
  stack?: string | undefined;