unknown-error 0.0.1 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +15 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,16 +14,7 @@ Turn any caught `unknown` into a real Error without throwing, even for hostile v
14
14
  - **Whole error trees**: Walks `cause` chains and `AggregateError` entries without recursion, so circular or 100,000-deep chains end instead of overflowing the stack.
15
15
  - **Doesn't modify your errors**: Errors are returned as they are, never patched in place.
16
16
 
17
- | | unknown-error | [normalize-exception](https://www.npmjs.com/package/normalize-exception) | [ensure-error](https://www.npmjs.com/package/ensure-error) | [serialize-error](https://www.npmjs.com/package/serialize-error) | [pony-cause](https://www.npmjs.com/package/pony-cause) |
18
- |---|---|---|---|---|---|
19
- | Never throws on hostile values | ✅ | ✅ | ❌ | ❌ | — |
20
- | Errors from other realms | ✅ | ✅ | ❌ | ✅ | ❌ |
21
- | Readable circular and BigInt values | ✅ | ❌ | ❌ | ❌ | — |
22
- | Leaves your errors unmodified | ✅ | ❌ | ❌ | ✅ | — |
23
- | Causes and `AggregateError` | ✅ | ✅ | ✅ | — | Causes only |
24
- | 10,000-deep cause chains | ✅ | ❌ | ❌ | — | ❌ |
25
-
26
- For the problems with hand-written conversions, the full comparison and design decisions, see [WHY-UNKNOWN-ERROR.md](https://github.com/JacobLey/leyman/blob/main/tools/unknown-error/WHY-UNKNOWN-ERROR.md).
17
+ For why it exists and the design decisions behind it, see [WHY-UNKNOWN-ERROR.md](https://github.com/JacobLey/leyman/blob/main/tools/unknown-error/WHY-UNKNOWN-ERROR.md).
27
18
 
28
19
  ## Contents
29
20
  - [Install](#install)
@@ -36,6 +27,7 @@ For the problems with hand-written conversions, the full comparison and design d
36
27
  - [`NonError`](#nonerror)
37
28
  - [`walkErrors(value, options?)`](#walkerrorsvalue-options)
38
29
  - [`formatError(value, options?)`](#formaterrorvalue-options)
30
+ - [Compared to alternatives](#compared-to-alternatives)
39
31
 
40
32
  ## Install
41
33
 
@@ -188,3 +180,16 @@ console.log(formatError(new Error('request failed', { cause: new Error('ECONNREF
188
180
  ```
189
181
 
190
182
  Causes are labelled `Caused by:`, and `AggregateError` entries `-`. Each error is printed as its `stack`, with a `Name: message` line added first when the stack doesn't start with one (as in Firefox and Safari). Where `maxDepth` cut the walk short, a `… more causes omitted` line says so.
183
+
184
+ ## Compared to alternatives
185
+
186
+ | | unknown-error | [normalize-exception](https://www.npmjs.com/package/normalize-exception) | [ensure-error](https://www.npmjs.com/package/ensure-error) | [serialize-error](https://www.npmjs.com/package/serialize-error) | [pony-cause](https://www.npmjs.com/package/pony-cause) |
187
+ |---|---|---|---|---|---|
188
+ | Never throws on hostile values | ✅ | ✅ | ❌ | ❌ | — |
189
+ | Errors from other realms | ✅ | ✅ | ❌ | ✅ | ❌ |
190
+ | Readable circular and BigInt values | ✅ | ❌ | ❌ | ❌ | — |
191
+ | Leaves your errors unmodified | ✅ | ❌ | ❌ | ✅ | — |
192
+ | Causes and `AggregateError` | ✅ | ✅ | ✅ | — | Causes only |
193
+ | 10,000-deep cause chains | ✅ | ❌ | ❌ | — | ❌ |
194
+
195
+ Each cell is checked by a [comparison test suite](https://github.com/JacobLey/leyman/blob/main/e2e/unknown-error-comparison/test/integration/comparison.spec.ts). For every case, and where hand-written conversions fall short, see [WHY-UNKNOWN-ERROR.md](https://github.com/JacobLey/leyman/blob/main/tools/unknown-error/WHY-UNKNOWN-ERROR.md#comparison).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unknown-error",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Turn any caught `unknown` into a real Error without throwing, even for hostile values, other realms and deep or circular cause chains",
5
5
  "engines": {
6
6
  "node": ">=24"