go-go-try 7.2.1 → 7.4.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/AGENTS.md +81 -23
- package/README.md +84 -18
- package/dist/index.cjs +104 -61
- package/dist/index.d.cts +217 -94
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +217 -94
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +102 -62
- package/package.json +3 -3
- package/src/assert.ts +59 -0
- package/src/goTry.ts +45 -0
- package/src/goTryAll.ts +141 -0
- package/src/goTryOr.ts +55 -0
- package/src/goTryRaw.ts +126 -0
- package/src/index.test.ts +411 -22
- package/src/index.ts +27 -459
- package/src/internals.ts +45 -0
- package/src/result-helpers.ts +46 -0
- package/src/tagged-error.ts +38 -0
- package/src/types.ts +64 -0
- package/src/unknown-error.ts +20 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { taggedError } from './tagged-error.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default system error class for errors that aren't already wrapped in a tagged error class.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // By default, goTryRaw wraps unknown errors in UnknownError
|
|
8
|
+
* const [err, result] = goTryRaw(() => mightThrow())
|
|
9
|
+
* if (err) {
|
|
10
|
+
* console.log(err._tag) // 'UnknownError'
|
|
11
|
+
* }
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Use a custom system error class
|
|
15
|
+
* const SystemError = taggedError('SystemError')
|
|
16
|
+
* const [err, result] = goTryRaw(() => mightThrow(), {
|
|
17
|
+
* systemErrorClass: SystemError
|
|
18
|
+
* })
|
|
19
|
+
*/
|
|
20
|
+
export const UnknownError = taggedError('UnknownError')
|