@xylabs/error 5.0.84 → 5.0.86

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.
Files changed (2) hide show
  1. package/README.md +46 -66
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
  Base functionality used throughout XY Labs TypeScript/JavaScript libraries
17
17
 
18
+
19
+
18
20
  ## Reference
19
21
 
20
22
  **@xylabs/error**
@@ -23,14 +25,18 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
23
25
 
24
26
  ## Type Aliases
25
27
 
26
- - [AssertConfig](#type-aliases/AssertConfig)
28
+ | Type Alias | Description |
29
+ | ------ | ------ |
30
+ | [AssertConfig](#type-aliases/AssertConfig) | Configuration for assertion behavior: a static message string, a boolean toggle, or a callback. |
27
31
 
28
32
  ## Functions
29
33
 
30
- - [assertError](#functions/assertError)
31
- - [handleError](#functions/handleError)
32
- - [handleErrorAsync](#functions/handleErrorAsync)
33
- - [isError](#functions/isError)
34
+ | Function | Description |
35
+ | ------ | ------ |
36
+ | [assertError](#functions/assertError) | Throws an Error based on the assert configuration when a value fails validation. |
37
+ | [handleError](#functions/handleError) | Invokes the handler if the value is an Error, otherwise re-throws it. |
38
+ | [handleErrorAsync](#functions/handleErrorAsync) | Async version of handleError. Invokes the async handler if the value is an Error, otherwise re-throws it. |
39
+ | [isError](#functions/isError) | Type guard that checks whether a value is an Error instance. |
34
40
 
35
41
  ### functions
36
42
 
@@ -42,32 +48,20 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
42
48
 
43
49
  ```ts
44
50
  function assertError(
45
- value,
46
- assert,
47
- defaultMessage): undefined;
51
+ value: unknown,
52
+ assert: AssertConfig | undefined,
53
+ defaultMessage: string): undefined;
48
54
  ```
49
55
 
50
56
  Throws an Error based on the assert configuration when a value fails validation.
51
57
 
52
58
  ## Parameters
53
59
 
54
- ### value
55
-
56
- `unknown`
57
-
58
- The value being validated
59
-
60
- ### assert
61
-
62
- Assertion config controlling the error message
63
-
64
- [`AssertConfig`](#../type-aliases/AssertConfig) | `undefined`
65
-
66
- ### defaultMessage
67
-
68
- `string`
69
-
70
- Fallback message if no custom message is provided
60
+ | Parameter | Type | Description |
61
+ | ------ | ------ | ------ |
62
+ | `value` | `unknown` | The value being validated |
63
+ | `assert` | [`AssertConfig`](#../type-aliases/AssertConfig) \| `undefined` | Assertion config controlling the error message |
64
+ | `defaultMessage` | `string` | Fallback message if no custom message is provided |
71
65
 
72
66
  ## Returns
73
67
 
@@ -80,30 +74,23 @@ Fallback message if no custom message is provided
80
74
  ***
81
75
 
82
76
  ```ts
83
- function handleError<T>(error, handler): T;
77
+ function handleError<T>(error: any, handler: (error: Error) => T): T;
84
78
  ```
85
79
 
86
80
  Invokes the handler if the value is an Error, otherwise re-throws it.
87
81
 
88
82
  ## Type Parameters
89
83
 
90
- ### T
91
-
92
- `T`
84
+ | Type Parameter |
85
+ | ------ |
86
+ | `T` |
93
87
 
94
88
  ## Parameters
95
89
 
96
- ### error
97
-
98
- `any`
99
-
100
- The caught value to inspect
101
-
102
- ### handler
103
-
104
- (`error`) => `T`
105
-
106
- Callback invoked with the Error if it is one
90
+ | Parameter | Type | Description |
91
+ | ------ | ------ | ------ |
92
+ | `error` | `any` | The caught value to inspect |
93
+ | `handler` | (`error`: `Error`) => `T` | Callback invoked with the Error if it is one |
107
94
 
108
95
  ## Returns
109
96
 
@@ -118,30 +105,23 @@ The handler's return value
118
105
  ***
119
106
 
120
107
  ```ts
121
- function handleErrorAsync<T>(error, handler): Promise<T>;
108
+ function handleErrorAsync<T>(error: any, handler: (error: Error) => Promise<T>): Promise<T>;
122
109
  ```
123
110
 
124
111
  Async version of handleError. Invokes the async handler if the value is an Error, otherwise re-throws it.
125
112
 
126
113
  ## Type Parameters
127
114
 
128
- ### T
129
-
130
- `T`
115
+ | Type Parameter |
116
+ | ------ |
117
+ | `T` |
131
118
 
132
119
  ## Parameters
133
120
 
134
- ### error
135
-
136
- `any`
137
-
138
- The caught value to inspect
139
-
140
- ### handler
141
-
142
- (`error`) => `Promise`\<`T`\>
143
-
144
- Async callback invoked with the Error if it is one
121
+ | Parameter | Type | Description |
122
+ | ------ | ------ | ------ |
123
+ | `error` | `any` | The caught value to inspect |
124
+ | `handler` | (`error`: `Error`) => `Promise`\<`T`\> | Async callback invoked with the Error if it is one |
145
125
 
146
126
  ## Returns
147
127
 
@@ -158,16 +138,16 @@ The handler's resolved return value
158
138
  ## Call Signature
159
139
 
160
140
  ```ts
161
- function isError(value): value is Error;
141
+ function isError(value: unknown): value is Error;
162
142
  ```
163
143
 
164
144
  Type guard that checks whether a value is an Error instance.
165
145
 
166
146
  ### Parameters
167
147
 
168
- ### value
169
-
170
- `unknown`
148
+ | Parameter | Type |
149
+ | ------ | ------ |
150
+ | `value` | `unknown` |
171
151
 
172
152
  ### Returns
173
153
 
@@ -176,22 +156,22 @@ Type guard that checks whether a value is an Error instance.
176
156
  ## Call Signature
177
157
 
178
158
  ```ts
179
- function isError<T>(value): value is Extract<T, Error>;
159
+ function isError<T>(value: T): value is Extract<T, Error>;
180
160
  ```
181
161
 
182
162
  Type guard that checks whether a value is an Error instance.
183
163
 
184
164
  ### Type Parameters
185
165
 
186
- ### T
187
-
188
- `T`
166
+ | Type Parameter |
167
+ | ------ |
168
+ | `T` |
189
169
 
190
170
  ### Parameters
191
171
 
192
- ### value
193
-
194
- `T`
172
+ | Parameter | Type |
173
+ | ------ | ------ |
174
+ | `value` | `T` |
195
175
 
196
176
  ### Returns
197
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/error",
3
- "version": "5.0.84",
3
+ "version": "5.0.86",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "error",
@@ -42,11 +42,11 @@
42
42
  "!**/*.test.*"
43
43
  ],
44
44
  "dependencies": {
45
- "@xylabs/typeof": "~5.0.84"
45
+ "@xylabs/typeof": "~5.0.86"
46
46
  },
47
47
  "devDependencies": {
48
- "@xylabs/ts-scripts-yarn3": "~7.4.13",
49
- "@xylabs/tsconfig": "~7.4.13",
48
+ "@xylabs/ts-scripts-yarn3": "~7.4.16",
49
+ "@xylabs/tsconfig": "~7.4.16",
50
50
  "typescript": "~5.9.3",
51
51
  "vitest": "^4.0.18"
52
52
  },