effect 3.12.7 → 3.12.8
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/dist/cjs/BigDecimal.js +1 -1
- package/dist/cjs/BigDecimal.js.map +1 -1
- package/dist/cjs/Cause.js +630 -167
- package/dist/cjs/Cause.js.map +1 -1
- package/dist/cjs/Chunk.js +4 -8
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/ConfigProvider.js +1 -0
- package/dist/cjs/ConfigProvider.js.map +1 -1
- package/dist/cjs/Cron.js +26 -10
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/Duration.js +7 -4
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +5 -24
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/Layer.js.map +1 -1
- package/dist/cjs/Option.js +1042 -363
- package/dist/cjs/Option.js.map +1 -1
- package/dist/cjs/ParseResult.js +41 -18
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schedule.js +8 -1
- package/dist/cjs/Schedule.js.map +1 -1
- package/dist/cjs/Schema.js +51 -10
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/cause.js +23 -108
- package/dist/cjs/internal/cause.js.map +1 -1
- package/dist/cjs/internal/core.js +4 -5
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/schedule.js.map +1 -1
- package/dist/cjs/internal/secret.js +6 -5
- package/dist/cjs/internal/secret.js.map +1 -1
- package/dist/cjs/internal/stream.js +21 -23
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/BigDecimal.d.ts.map +1 -1
- package/dist/dts/Cause.d.ts +1157 -304
- package/dist/dts/Cause.d.ts.map +1 -1
- package/dist/dts/Chunk.d.ts +3 -6
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/ConfigProvider.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +25 -9
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +1 -1
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +3 -2
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +1 -1
- package/dist/dts/Layer.d.ts.map +1 -1
- package/dist/dts/Option.d.ts +2288 -784
- package/dist/dts/Option.d.ts.map +1 -1
- package/dist/dts/ParseResult.d.ts +4 -4
- package/dist/dts/ParseResult.d.ts.map +1 -1
- package/dist/dts/Schedule.d.ts +7 -0
- package/dist/dts/Schedule.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +15 -4
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/BigDecimal.js +1 -1
- package/dist/esm/BigDecimal.js.map +1 -1
- package/dist/esm/Cause.js +630 -167
- package/dist/esm/Cause.js.map +1 -1
- package/dist/esm/Chunk.js +4 -8
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/ConfigProvider.js +1 -0
- package/dist/esm/ConfigProvider.js.map +1 -1
- package/dist/esm/Cron.js +27 -11
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/Duration.js +7 -4
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +5 -24
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/Layer.js.map +1 -1
- package/dist/esm/Option.js +1041 -363
- package/dist/esm/Option.js.map +1 -1
- package/dist/esm/ParseResult.js +41 -18
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schedule.js +7 -0
- package/dist/esm/Schedule.js.map +1 -1
- package/dist/esm/Schema.js +51 -10
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/internal/cause.js +22 -108
- package/dist/esm/internal/cause.js.map +1 -1
- package/dist/esm/internal/core.js +4 -5
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/schedule.js.map +1 -1
- package/dist/esm/internal/secret.js +5 -4
- package/dist/esm/internal/secret.js.map +1 -1
- package/dist/esm/internal/stream.js +21 -23
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +1 -1
- package/src/Cause.ts +1158 -304
- package/src/Chunk.ts +8 -11
- package/src/ConfigProvider.ts +1 -0
- package/src/Cron.ts +28 -11
- package/src/Duration.ts +10 -5
- package/src/Effect.ts +5 -2
- package/src/Either.ts +11 -28
- package/src/Layer.ts +1 -1
- package/src/Option.ts +2314 -820
- package/src/ParseResult.ts +53 -29
- package/src/Schedule.ts +8 -0
- package/src/Schema.ts +68 -12
- package/src/internal/cause.ts +38 -137
- package/src/internal/core.ts +4 -5
- package/src/internal/layer.ts +1 -1
- package/src/internal/schedule.ts +7 -6
- package/src/internal/secret.ts +6 -4
- package/src/internal/stream.ts +24 -37
- package/src/internal/version.ts +1 -1
package/dist/cjs/Cause.js
CHANGED
|
@@ -9,456 +9,889 @@ var core = _interopRequireWildcard(require("./internal/core.js"));
|
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
/**
|
|
12
|
+
* A unique symbol identifying the `Cause` type.
|
|
13
|
+
*
|
|
14
|
+
* **Details**
|
|
15
|
+
*
|
|
16
|
+
* This provides a symbol that helps identify instances of the `Cause` data
|
|
17
|
+
* type. This can be used for advanced operations such as refining types or
|
|
18
|
+
* building internal utilities that check whether an unknown value is a `Cause`.
|
|
19
|
+
*
|
|
20
|
+
* @see {@link isCause} Check if a value is a `Cause`
|
|
12
21
|
* @since 2.0.0
|
|
13
|
-
* @category
|
|
22
|
+
* @category Symbols
|
|
14
23
|
*/
|
|
15
24
|
const CauseTypeId = exports.CauseTypeId = internal.CauseTypeId;
|
|
16
25
|
/**
|
|
26
|
+
* A unique symbol identifying the `RuntimeException` type.
|
|
27
|
+
*
|
|
28
|
+
* **Details**
|
|
29
|
+
*
|
|
30
|
+
* This provides a symbol that identifies a `RuntimeException`. This is
|
|
31
|
+
* typically used internally by the library to recognize checked exceptions that
|
|
32
|
+
* occur during runtime.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link RuntimeException} Create or work with a `RuntimeException`
|
|
35
|
+
*
|
|
17
36
|
* @since 2.0.0
|
|
18
|
-
* @category
|
|
37
|
+
* @category Symbols
|
|
19
38
|
*/
|
|
20
39
|
const RuntimeExceptionTypeId = exports.RuntimeExceptionTypeId = core.RuntimeExceptionTypeId;
|
|
21
40
|
/**
|
|
41
|
+
* A unique symbol identifying the `InterruptedException` type.
|
|
42
|
+
*
|
|
43
|
+
* **Details**
|
|
44
|
+
*
|
|
45
|
+
* This provides a symbol that identifies an `InterruptedException`. This is
|
|
46
|
+
* typically used internally to recognize when a fiber has been interrupted,
|
|
47
|
+
* helping the framework handle interruption logic correctly.
|
|
48
|
+
*
|
|
49
|
+
* @see {@link InterruptedException} Create or work with an `InterruptedException`
|
|
50
|
+
*
|
|
22
51
|
* @since 2.0.0
|
|
23
|
-
* @category
|
|
52
|
+
* @category Symbols
|
|
24
53
|
*/
|
|
25
54
|
const InterruptedExceptionTypeId = exports.InterruptedExceptionTypeId = core.InterruptedExceptionTypeId;
|
|
26
55
|
/**
|
|
56
|
+
* A unique symbol identifying the `IllegalArgumentException` type.
|
|
57
|
+
*
|
|
58
|
+
* **Details**
|
|
59
|
+
*
|
|
60
|
+
* This provides a symbol that identifies an `IllegalArgumentException`. This is
|
|
61
|
+
* often used in scenarios where invalid arguments are supplied to methods that
|
|
62
|
+
* expect specific input.
|
|
63
|
+
*
|
|
64
|
+
* @see {@link IllegalArgumentException} Create or work with an `IllegalArgumentException`
|
|
65
|
+
*
|
|
27
66
|
* @since 2.0.0
|
|
28
|
-
* @category
|
|
67
|
+
* @category Symbols
|
|
29
68
|
*/
|
|
30
69
|
const IllegalArgumentExceptionTypeId = exports.IllegalArgumentExceptionTypeId = core.IllegalArgumentExceptionTypeId;
|
|
31
70
|
/**
|
|
71
|
+
* A unique symbol identifying the `NoSuchElementException` type.
|
|
72
|
+
*
|
|
73
|
+
* **Details**
|
|
74
|
+
*
|
|
75
|
+
* This provides a symbol that identifies a `NoSuchElementException`. It helps
|
|
76
|
+
* differentiate cases where a required element is missing within a data
|
|
77
|
+
* structure.
|
|
78
|
+
*
|
|
79
|
+
* @see {@link NoSuchElementException} Create or work with a `NoSuchElementException`
|
|
80
|
+
*
|
|
32
81
|
* @since 2.0.0
|
|
33
|
-
* @category
|
|
82
|
+
* @category Symbols
|
|
34
83
|
*/
|
|
35
84
|
const NoSuchElementExceptionTypeId = exports.NoSuchElementExceptionTypeId = core.NoSuchElementExceptionTypeId;
|
|
36
85
|
/**
|
|
86
|
+
* A unique symbol identifying the `InvalidPubSubCapacityException` type.
|
|
87
|
+
*
|
|
88
|
+
* **Details**
|
|
89
|
+
*
|
|
90
|
+
* This provides a symbol that identifies an `InvalidPubSubCapacityException`.
|
|
91
|
+
* It indicates an error related to an invalid capacity passed to a `PubSub`
|
|
92
|
+
* structure.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link InvalidPubSubCapacityException} Create or work with an `InvalidPubSubCapacityException`
|
|
95
|
+
*
|
|
37
96
|
* @since 2.0.0
|
|
38
|
-
* @category
|
|
97
|
+
* @category Symbols
|
|
39
98
|
*/
|
|
40
99
|
const InvalidPubSubCapacityExceptionTypeId = exports.InvalidPubSubCapacityExceptionTypeId = core.InvalidPubSubCapacityExceptionTypeId;
|
|
41
100
|
/**
|
|
101
|
+
* A unique symbol identifying the `ExceededCapacityException` type.
|
|
102
|
+
*
|
|
103
|
+
* **Details**
|
|
104
|
+
*
|
|
105
|
+
* This provides a symbol that identifies an `ExceededCapacityException`. It
|
|
106
|
+
* denotes situations where a resource has exceeded its configured capacity
|
|
107
|
+
* limit.
|
|
108
|
+
*
|
|
109
|
+
* @see {@link ExceededCapacityException} Create or work with an `ExceededCapacityException`
|
|
110
|
+
*
|
|
42
111
|
* @since 3.5.0
|
|
43
|
-
* @category
|
|
112
|
+
* @category Symbols
|
|
44
113
|
*/
|
|
45
114
|
const ExceededCapacityExceptionTypeId = exports.ExceededCapacityExceptionTypeId = core.ExceededCapacityExceptionTypeId;
|
|
46
115
|
/**
|
|
116
|
+
* A unique symbol identifying the `TimeoutException` type.
|
|
117
|
+
*
|
|
118
|
+
* **Details**
|
|
119
|
+
*
|
|
120
|
+
* This provides a symbol that identifies a `TimeoutException`. It helps the
|
|
121
|
+
* framework recognize errors related to operations that fail to complete within
|
|
122
|
+
* a given timeframe.
|
|
123
|
+
*
|
|
124
|
+
* @see {@link TimeoutException} Create or work with a `TimeoutException`
|
|
125
|
+
*
|
|
47
126
|
* @since 2.0.0
|
|
48
|
-
* @category
|
|
127
|
+
* @category Symbols
|
|
49
128
|
*/
|
|
50
129
|
const TimeoutExceptionTypeId = exports.TimeoutExceptionTypeId = core.TimeoutExceptionTypeId;
|
|
51
130
|
/**
|
|
131
|
+
* A unique symbol identifying the `UnknownException` type.
|
|
132
|
+
*
|
|
133
|
+
* **Details**
|
|
134
|
+
*
|
|
135
|
+
* This provides a symbol that identifies an `UnknownException`. It is typically
|
|
136
|
+
* used for generic or unexpected errors that do not fit other specific
|
|
137
|
+
* exception categories.
|
|
138
|
+
*
|
|
139
|
+
* @see {@link UnknownException} Create or work with an `UnknownException`
|
|
140
|
+
*
|
|
52
141
|
* @since 2.0.0
|
|
53
|
-
* @category
|
|
142
|
+
* @category Symbols
|
|
54
143
|
*/
|
|
55
144
|
const UnknownExceptionTypeId = exports.UnknownExceptionTypeId = core.UnknownExceptionTypeId;
|
|
56
145
|
/**
|
|
57
|
-
*
|
|
146
|
+
* Creates an error that occurs at runtime, extendable for other exception
|
|
147
|
+
* types.
|
|
58
148
|
*
|
|
59
149
|
* @since 2.0.0
|
|
60
|
-
* @category
|
|
150
|
+
* @category Errors
|
|
61
151
|
*/
|
|
62
152
|
const YieldableError = exports.YieldableError = core.YieldableError;
|
|
63
153
|
/**
|
|
64
|
-
*
|
|
154
|
+
* Creates an `Empty` cause.
|
|
155
|
+
*
|
|
156
|
+
* **Details**
|
|
157
|
+
*
|
|
158
|
+
* This function returns a cause that signifies "no error." It's commonly used
|
|
159
|
+
* to represent an absence of failure conditions.
|
|
160
|
+
*
|
|
161
|
+
* @see {@link isEmpty} Check if a `Cause` is empty
|
|
65
162
|
*
|
|
66
163
|
* @since 2.0.0
|
|
67
|
-
* @category
|
|
164
|
+
* @category Constructors
|
|
68
165
|
*/
|
|
69
166
|
const empty = exports.empty = internal.empty;
|
|
70
167
|
/**
|
|
71
|
-
*
|
|
168
|
+
* Creates a `Fail` cause from an expected error.
|
|
169
|
+
*
|
|
170
|
+
* **Details**
|
|
171
|
+
*
|
|
172
|
+
* This function constructs a `Cause` carrying an error of type `E`. It's used
|
|
173
|
+
* when you want to represent a known or anticipated failure in your effectful
|
|
174
|
+
* computations.
|
|
175
|
+
*
|
|
176
|
+
* @see {@link isFailure} Check if a `Cause` contains a failure
|
|
72
177
|
*
|
|
73
178
|
* @since 2.0.0
|
|
74
|
-
* @category
|
|
179
|
+
* @category Constructors
|
|
75
180
|
*/
|
|
76
181
|
const fail = exports.fail = internal.fail;
|
|
77
182
|
/**
|
|
78
|
-
*
|
|
183
|
+
* Creates a `Die` cause from an unexpected error.
|
|
184
|
+
*
|
|
185
|
+
* **Details**
|
|
186
|
+
*
|
|
187
|
+
* This function wraps an unhandled or unknown defect (like a runtime crash)
|
|
188
|
+
* into a `Cause`. It's useful for capturing unforeseen issues in a structured
|
|
189
|
+
* way.
|
|
190
|
+
*
|
|
191
|
+
* @see {@link isDie} Check if a `Cause` contains a defect
|
|
79
192
|
*
|
|
80
193
|
* @since 2.0.0
|
|
81
|
-
* @category
|
|
194
|
+
* @category Constructors
|
|
82
195
|
*/
|
|
83
196
|
const die = exports.die = internal.die;
|
|
84
197
|
/**
|
|
85
|
-
*
|
|
198
|
+
* Creates an `Interrupt` cause from a `FiberId`.
|
|
199
|
+
*
|
|
200
|
+
* **Details**
|
|
201
|
+
*
|
|
202
|
+
* This function represents a fiber that has been interrupted. It stores the
|
|
203
|
+
* identifier of the interrupted fiber, enabling precise tracking of concurrent
|
|
204
|
+
* cancellations.
|
|
205
|
+
*
|
|
206
|
+
* @see {@link isInterrupted} Check if a `Cause` contains an interruption
|
|
86
207
|
*
|
|
87
208
|
* @since 2.0.0
|
|
88
|
-
* @category
|
|
209
|
+
* @category Constructors
|
|
89
210
|
*/
|
|
90
211
|
const interrupt = exports.interrupt = internal.interrupt;
|
|
91
212
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
213
|
+
* Combines two `Cause`s in parallel.
|
|
214
|
+
*
|
|
215
|
+
* **Details**
|
|
216
|
+
*
|
|
217
|
+
* This function merges two errors that occurred simultaneously. Instead of
|
|
218
|
+
* discarding one error, both are retained, allowing for richer error reporting
|
|
219
|
+
* and debugging.
|
|
220
|
+
*
|
|
221
|
+
* @see {@link isParallelType} Check if a `Cause` is a `Parallel`
|
|
94
222
|
*
|
|
95
223
|
* @since 2.0.0
|
|
96
|
-
* @category
|
|
224
|
+
* @category Constructors
|
|
97
225
|
*/
|
|
98
226
|
const parallel = exports.parallel = internal.parallel;
|
|
99
227
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
228
|
+
* Combines two `Cause`s sequentially.
|
|
229
|
+
*
|
|
230
|
+
* **Details**
|
|
231
|
+
*
|
|
232
|
+
* This function merges two errors that occurred in sequence, such as a main
|
|
233
|
+
* error followed by a finalization error. It preserves both errors for complete
|
|
234
|
+
* failure information.
|
|
235
|
+
*
|
|
236
|
+
* @see {@link isSequentialType} Check if a `Cause` is a `Sequential`
|
|
102
237
|
*
|
|
103
238
|
* @since 2.0.0
|
|
104
|
-
* @category
|
|
239
|
+
* @category Constructors
|
|
105
240
|
*/
|
|
106
241
|
const sequential = exports.sequential = internal.sequential;
|
|
107
242
|
/**
|
|
108
|
-
*
|
|
243
|
+
* Checks if a value is a `Cause`.
|
|
109
244
|
*
|
|
110
245
|
* @since 2.0.0
|
|
111
|
-
* @category
|
|
246
|
+
* @category Guards
|
|
112
247
|
*/
|
|
113
248
|
const isCause = exports.isCause = internal.isCause;
|
|
114
249
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
250
|
+
* Checks if a `Cause` is an `Empty` type.
|
|
251
|
+
*
|
|
252
|
+
* @see {@link empty} Create a new `Empty` cause
|
|
117
253
|
*
|
|
118
254
|
* @since 2.0.0
|
|
119
|
-
* @category
|
|
255
|
+
* @category Guards
|
|
120
256
|
*/
|
|
121
257
|
const isEmptyType = exports.isEmptyType = internal.isEmptyType;
|
|
122
258
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
259
|
+
* Checks if a `Cause` is a `Fail` type.
|
|
260
|
+
*
|
|
261
|
+
* @see {@link fail} Create a new `Fail` cause
|
|
125
262
|
*
|
|
126
263
|
* @since 2.0.0
|
|
127
|
-
* @category
|
|
264
|
+
* @category Guards
|
|
128
265
|
*/
|
|
129
266
|
const isFailType = exports.isFailType = internal.isFailType;
|
|
130
267
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
268
|
+
* Checks if a `Cause` is a `Die` type.
|
|
269
|
+
*
|
|
270
|
+
* @see {@link die} Create a new `Die` cause
|
|
133
271
|
*
|
|
134
272
|
* @since 2.0.0
|
|
135
|
-
* @category
|
|
273
|
+
* @category Guards
|
|
136
274
|
*/
|
|
137
275
|
const isDieType = exports.isDieType = internal.isDieType;
|
|
138
276
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
277
|
+
* Checks if a `Cause` is an `Interrupt` type.
|
|
278
|
+
*
|
|
279
|
+
* @see {@link interrupt} Create an `Interrupt` cause
|
|
141
280
|
*
|
|
142
281
|
* @since 2.0.0
|
|
143
|
-
* @category
|
|
282
|
+
* @category Guards
|
|
144
283
|
*/
|
|
145
284
|
const isInterruptType = exports.isInterruptType = internal.isInterruptType;
|
|
146
285
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
286
|
+
* Checks if a `Cause` is a `Sequential` type.
|
|
287
|
+
*
|
|
288
|
+
* @see {@link sequential} Combine two `Cause`s sequentially
|
|
149
289
|
*
|
|
150
290
|
* @since 2.0.0
|
|
151
|
-
* @category
|
|
291
|
+
* @category Guards
|
|
152
292
|
*/
|
|
153
293
|
const isSequentialType = exports.isSequentialType = internal.isSequentialType;
|
|
154
294
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
295
|
+
* Checks if a `Cause` is a `Parallel` type.
|
|
296
|
+
*
|
|
297
|
+
* @see {@link parallel} Combine two `Cause`s in parallel
|
|
157
298
|
*
|
|
158
299
|
* @since 2.0.0
|
|
159
|
-
* @category
|
|
300
|
+
* @category Guards
|
|
160
301
|
*/
|
|
161
302
|
const isParallelType = exports.isParallelType = internal.isParallelType;
|
|
162
303
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
304
|
+
* Calculates the size of a `Cause`.
|
|
305
|
+
*
|
|
306
|
+
* **Details**
|
|
307
|
+
*
|
|
308
|
+
* This function returns the total number of `Cause` nodes in the semiring
|
|
309
|
+
* structure, reflecting how many individual error elements are recorded.
|
|
165
310
|
*
|
|
166
311
|
* @since 2.0.0
|
|
167
|
-
* @category
|
|
312
|
+
* @category Getters
|
|
168
313
|
*/
|
|
169
314
|
const size = exports.size = internal.size;
|
|
170
315
|
/**
|
|
171
|
-
*
|
|
316
|
+
* Checks if a `Cause` is entirely empty.
|
|
317
|
+
*
|
|
318
|
+
* **Details**
|
|
319
|
+
*
|
|
320
|
+
* This function returns `true` if the `Cause` contains no errors, defects, or
|
|
321
|
+
* interruptions. It's helpful for verifying if a computation truly had no
|
|
322
|
+
* failures.
|
|
172
323
|
*
|
|
173
324
|
* @since 2.0.0
|
|
174
|
-
* @category
|
|
325
|
+
* @category Getters
|
|
175
326
|
*/
|
|
176
327
|
const isEmpty = exports.isEmpty = internal.isEmpty;
|
|
177
328
|
/**
|
|
178
|
-
*
|
|
329
|
+
* Checks if a `Cause` contains a failure.
|
|
330
|
+
*
|
|
331
|
+
* **Details**
|
|
332
|
+
*
|
|
333
|
+
* This function returns `true` if the `Cause` includes any `Fail` error. It's
|
|
334
|
+
* commonly used to confirm whether a workflow encountered an anticipated error
|
|
335
|
+
* versus just defects or interruptions.
|
|
179
336
|
*
|
|
180
337
|
* @since 2.0.0
|
|
181
|
-
* @category
|
|
338
|
+
* @category Getters
|
|
182
339
|
*/
|
|
183
340
|
const isFailure = exports.isFailure = internal.isFailure;
|
|
184
341
|
/**
|
|
185
|
-
*
|
|
342
|
+
* Checks if a `Cause` contains a defect.
|
|
343
|
+
*
|
|
344
|
+
* **Details**
|
|
345
|
+
*
|
|
346
|
+
* This function returns `true` if the `Cause` includes any unexpected or
|
|
347
|
+
* unhandled errors (`Die`). It's useful for differentiating known failures from
|
|
348
|
+
* unexpected ones.
|
|
186
349
|
*
|
|
187
350
|
* @since 2.0.0
|
|
188
|
-
* @category
|
|
351
|
+
* @category Getters
|
|
189
352
|
*/
|
|
190
353
|
const isDie = exports.isDie = internal.isDie;
|
|
191
354
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
355
|
+
* Checks if a `Cause` contains an interruption.
|
|
356
|
+
*
|
|
357
|
+
* **Details**
|
|
358
|
+
*
|
|
359
|
+
* This function returns `true` if the `Cause` includes any fiber interruptions.
|
|
194
360
|
*
|
|
195
361
|
* @since 2.0.0
|
|
196
|
-
* @category
|
|
362
|
+
* @category Getters
|
|
197
363
|
*/
|
|
198
364
|
const isInterrupted = exports.isInterrupted = internal.isInterrupted;
|
|
199
365
|
/**
|
|
200
|
-
*
|
|
201
|
-
*
|
|
366
|
+
* Checks if a `Cause` contains only interruptions.
|
|
367
|
+
*
|
|
368
|
+
* **Details**
|
|
369
|
+
*
|
|
370
|
+
* This function returns `true` if the `Cause` has been interrupted but does not
|
|
371
|
+
* contain any other failures, such as `Fail` or `Die`. It's helpful for
|
|
372
|
+
* verifying purely "cancellation" scenarios.
|
|
202
373
|
*
|
|
203
374
|
* @since 2.0.0
|
|
204
|
-
* @category
|
|
375
|
+
* @category Getters
|
|
205
376
|
*/
|
|
206
377
|
const isInterruptedOnly = exports.isInterruptedOnly = internal.isInterruptedOnly;
|
|
207
378
|
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
379
|
+
* Extracts all recoverable errors of type `E` from a `Cause`.
|
|
380
|
+
*
|
|
381
|
+
* **Details**
|
|
382
|
+
*
|
|
383
|
+
* This function returns a chunk of errors, providing a list of all `Fail`
|
|
384
|
+
* values found in the cause. It's useful for collecting all known failures for
|
|
385
|
+
* logging or combined error handling.
|
|
210
386
|
*
|
|
211
387
|
* @since 2.0.0
|
|
212
|
-
* @category
|
|
388
|
+
* @category Getters
|
|
213
389
|
*/
|
|
214
390
|
const failures = exports.failures = internal.failures;
|
|
215
391
|
/**
|
|
216
|
-
*
|
|
392
|
+
* Extracts all unrecoverable defects from a `Cause`.
|
|
393
|
+
*
|
|
394
|
+
* **Details**
|
|
395
|
+
*
|
|
396
|
+
* This function returns a chunk of values representing unexpected errors
|
|
397
|
+
* (`Die`). It's handy for capturing or logging unanticipated failures that
|
|
398
|
+
* might need special handling, such as bug reports.
|
|
217
399
|
*
|
|
218
400
|
* @since 2.0.0
|
|
219
|
-
* @category
|
|
401
|
+
* @category Getters
|
|
220
402
|
*/
|
|
221
403
|
const defects = exports.defects = internal.defects;
|
|
222
404
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
405
|
+
* Collects all `FiberId`s responsible for interrupting a fiber.
|
|
406
|
+
*
|
|
407
|
+
* **Details**
|
|
408
|
+
*
|
|
409
|
+
* This function returns a set of IDs indicating which fibers caused
|
|
410
|
+
* interruptions within this `Cause`. It's useful for debugging concurrency
|
|
411
|
+
* issues or tracing cancellations.
|
|
225
412
|
*
|
|
226
413
|
* @since 2.0.0
|
|
227
|
-
* @category
|
|
414
|
+
* @category Getters
|
|
228
415
|
*/
|
|
229
416
|
const interruptors = exports.interruptors = internal.interruptors;
|
|
230
417
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
418
|
+
* Retrieves the first `Fail` error in a `Cause`, if present.
|
|
419
|
+
*
|
|
420
|
+
* **Details**
|
|
421
|
+
*
|
|
422
|
+
* This function returns an `Option` containing the first recoverable error
|
|
423
|
+
* (`E`) from the cause. It's often used to quickly check if there's a primary
|
|
424
|
+
* error to handle or display.
|
|
233
425
|
*
|
|
234
426
|
* @since 2.0.0
|
|
235
|
-
* @category
|
|
427
|
+
* @category Getters
|
|
236
428
|
*/
|
|
237
429
|
const failureOption = exports.failureOption = internal.failureOption;
|
|
238
430
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
431
|
+
* Splits a `Cause` into either its first `Fail` error or the rest of the cause
|
|
432
|
+
* (which might only contain `Die` or `Interrupt`).
|
|
433
|
+
*
|
|
434
|
+
* **Details**
|
|
435
|
+
*
|
|
436
|
+
* This function either returns the checked error (`E`) or the remaining
|
|
437
|
+
* `Cause<never>` with defects/interruptions. It helps you decide if there's a
|
|
438
|
+
* recoverable path or if only unhandled issues remain.
|
|
242
439
|
*
|
|
243
440
|
* @since 2.0.0
|
|
244
|
-
* @category
|
|
441
|
+
* @category Getters
|
|
245
442
|
*/
|
|
246
443
|
const failureOrCause = exports.failureOrCause = internal.failureOrCause;
|
|
247
444
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
445
|
+
* Strips out failures with an error of `None` from a `Cause<Option<E>>`.
|
|
446
|
+
*
|
|
447
|
+
* **Details**
|
|
448
|
+
*
|
|
449
|
+
* This function turns a `Cause<Option<E>>` into an `Option<Cause<E>>`. If the
|
|
450
|
+
* cause only contains failures of `None`, it becomes `None`; otherwise, it
|
|
451
|
+
* returns a `Cause` of the remaining errors. It's helpful when working with
|
|
452
|
+
* optional errors and filtering out certain error paths.
|
|
250
453
|
*
|
|
251
454
|
* @since 2.0.0
|
|
252
|
-
* @category
|
|
455
|
+
* @category Getters
|
|
253
456
|
*/
|
|
254
457
|
const flipCauseOption = exports.flipCauseOption = internal.flipCauseOption;
|
|
255
458
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
459
|
+
* Retrieves the first `Die` defect in a `Cause`, if present.
|
|
460
|
+
*
|
|
461
|
+
* **Details**
|
|
462
|
+
*
|
|
463
|
+
* This function returns an `Option` containing the first unexpected failure
|
|
464
|
+
* (`Die`) discovered. It's helpful for diagnosing the primary defect in a chain
|
|
465
|
+
* of errors.
|
|
258
466
|
*
|
|
259
467
|
* @since 2.0.0
|
|
260
|
-
* @category
|
|
468
|
+
* @category Getters
|
|
261
469
|
*/
|
|
262
470
|
const dieOption = exports.dieOption = internal.dieOption;
|
|
263
471
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
472
|
+
* Retrieves the first `Interrupt` in a `Cause`, if present.
|
|
473
|
+
*
|
|
474
|
+
* **Details**
|
|
475
|
+
*
|
|
476
|
+
* This function returns an `Option` with the first fiber interruption
|
|
477
|
+
* discovered. This is particularly useful for concurrency analysis or debugging
|
|
478
|
+
* cancellations.
|
|
266
479
|
*
|
|
267
480
|
* @since 2.0.0
|
|
268
|
-
* @category
|
|
481
|
+
* @category Getters
|
|
269
482
|
*/
|
|
270
483
|
const interruptOption = exports.interruptOption = internal.interruptOption;
|
|
271
484
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
485
|
+
* Removes all `Fail` and `Interrupt` nodes, keeping only defects (`Die`) in a
|
|
486
|
+
* `Cause`.
|
|
487
|
+
*
|
|
488
|
+
* **Details**
|
|
489
|
+
*
|
|
490
|
+
* This function strips a cause of recoverable errors and interruptions, leaving
|
|
491
|
+
* only unexpected failures. If no defects remain, it returns `None`. It's
|
|
492
|
+
* valuable for focusing only on unanticipated problems when both known errors
|
|
493
|
+
* and defects could occur.
|
|
274
494
|
*
|
|
275
495
|
* @since 2.0.0
|
|
276
|
-
* @category
|
|
496
|
+
* @category Getters
|
|
277
497
|
*/
|
|
278
498
|
const keepDefects = exports.keepDefects = internal.keepDefects;
|
|
499
|
+
// TODO(4.0): remove? what's the point of this API?
|
|
279
500
|
/**
|
|
280
|
-
* Linearizes
|
|
281
|
-
*
|
|
501
|
+
* Linearizes a `Cause` into a set of parallel causes, each containing a
|
|
502
|
+
* sequential chain of failures.
|
|
503
|
+
*
|
|
504
|
+
* **Details**
|
|
505
|
+
*
|
|
506
|
+
* This function reorganizes the cause structure so that you can analyze each
|
|
507
|
+
* parallel branch separately, even if they have multiple sequential errors.
|
|
282
508
|
*
|
|
283
509
|
* @since 2.0.0
|
|
284
|
-
* @category
|
|
510
|
+
* @category Getters
|
|
285
511
|
*/
|
|
286
512
|
const linearize = exports.linearize = internal.linearize;
|
|
287
513
|
/**
|
|
288
|
-
*
|
|
289
|
-
*
|
|
514
|
+
* Removes `Fail` and `Interrupt` nodes from a `Cause`, keeping only defects
|
|
515
|
+
* (`Die`).
|
|
516
|
+
*
|
|
517
|
+
* **Details**
|
|
518
|
+
*
|
|
519
|
+
* This function is similar to `keepDefects` but returns a `Cause<never>`
|
|
520
|
+
* directly, which can still store `Die` or finalizer-related defects. It's
|
|
521
|
+
* helpful for analyzing only the irrecoverable portion of the error.
|
|
290
522
|
*
|
|
291
523
|
* @since 2.0.0
|
|
292
|
-
* @category
|
|
524
|
+
* @category Getters
|
|
293
525
|
*/
|
|
294
526
|
const stripFailures = exports.stripFailures = internal.stripFailures;
|
|
295
527
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
528
|
+
* Removes matching defects from a `Cause` using a partial function, returning
|
|
529
|
+
* the remainder.
|
|
530
|
+
*
|
|
531
|
+
* **Details**
|
|
532
|
+
*
|
|
533
|
+
* This function applies a user-defined extraction function to each defect
|
|
534
|
+
* (`Die`). If the function matches the defect, that defect is removed. If all
|
|
535
|
+
* defects match, the result is `None`. Otherwise, you get a `Cause` with the
|
|
536
|
+
* unmatched defects.
|
|
299
537
|
*
|
|
300
538
|
* @since 2.0.0
|
|
301
|
-
* @category
|
|
539
|
+
* @category Getters
|
|
302
540
|
*/
|
|
303
541
|
const stripSomeDefects = exports.stripSomeDefects = internal.stripSomeDefects;
|
|
304
542
|
/**
|
|
543
|
+
* Replaces any errors in a `Cause` with a provided constant error.
|
|
544
|
+
*
|
|
545
|
+
* **Details**
|
|
546
|
+
*
|
|
547
|
+
* This function transforms all `Fail` errors into the specified error value,
|
|
548
|
+
* preserving the structure of the `Cause`. It's useful when you no longer need
|
|
549
|
+
* the original error details but still want to keep the cause shape.
|
|
550
|
+
*
|
|
551
|
+
* @see {@link map} Apply a custom transformation to `Fail` errors
|
|
552
|
+
*
|
|
305
553
|
* @since 2.0.0
|
|
306
|
-
* @category
|
|
554
|
+
* @category Mapping
|
|
307
555
|
*/
|
|
308
556
|
const as = exports.as = internal.as;
|
|
309
557
|
/**
|
|
558
|
+
* Transforms the errors in a `Cause` using a user-provided function.
|
|
559
|
+
*
|
|
560
|
+
* **Details**
|
|
561
|
+
*
|
|
562
|
+
* This function applies `f` to each `Fail` error while leaving defects (`Die`)
|
|
563
|
+
* and interruptions untouched. It's useful for changing or simplifying error
|
|
564
|
+
* types in your effectful workflows.
|
|
565
|
+
*
|
|
566
|
+
* @see {@link as} Replace errors with a single constant
|
|
567
|
+
*
|
|
310
568
|
* @since 2.0.0
|
|
311
|
-
* @category
|
|
569
|
+
* @category Mapping
|
|
312
570
|
*/
|
|
313
571
|
const map = exports.map = internal.map;
|
|
314
572
|
/**
|
|
573
|
+
* Transforms errors in a `Cause` into new causes.
|
|
574
|
+
*
|
|
575
|
+
* **Details**
|
|
576
|
+
*
|
|
577
|
+
* This function applies a function `f` to each `Fail` error, converting it into
|
|
578
|
+
* a new `Cause`. This is especially powerful for merging or restructuring error
|
|
579
|
+
* types while preserving or combining cause information.
|
|
580
|
+
*
|
|
581
|
+
* @see {@link map} Apply a simpler transformation to errors
|
|
582
|
+
*
|
|
315
583
|
* @since 2.0.0
|
|
316
|
-
* @category
|
|
584
|
+
* @category Sequencing
|
|
317
585
|
*/
|
|
318
586
|
const flatMap = exports.flatMap = internal.flatMap;
|
|
319
587
|
/**
|
|
320
|
-
*
|
|
588
|
+
* Sequences two `Cause`s. The second `Cause` can be dependent on the result of
|
|
589
|
+
* the first `Cause`.
|
|
321
590
|
*
|
|
322
591
|
* @since 2.0.0
|
|
323
|
-
* @category
|
|
592
|
+
* @category Sequencing
|
|
324
593
|
*/
|
|
325
594
|
const andThen = exports.andThen = internal.andThen;
|
|
326
595
|
/**
|
|
596
|
+
* Flattens a nested `Cause` structure.
|
|
597
|
+
*
|
|
598
|
+
* **Details**
|
|
599
|
+
*
|
|
600
|
+
* This function takes a `Cause<Cause<E>>` and merges the layers into a single
|
|
601
|
+
* `Cause<E>`. It's useful for eliminating additional nesting created by
|
|
602
|
+
* repeated transformations or compositions.
|
|
603
|
+
*
|
|
604
|
+
* @see {@link flatMap} Compose nested causes
|
|
605
|
+
*
|
|
327
606
|
* @since 2.0.0
|
|
328
|
-
* @category
|
|
607
|
+
* @category Sequencing
|
|
329
608
|
*/
|
|
330
609
|
const flatten = exports.flatten = internal.flatten;
|
|
331
610
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
611
|
+
* Checks if the current `Cause` contains or is equal to another `Cause`.
|
|
612
|
+
*
|
|
613
|
+
* **Details**
|
|
614
|
+
*
|
|
615
|
+
* This function returns `true` if `that` cause is part of or the same as
|
|
616
|
+
* the current `Cause`. It's useful when you need to check for specific
|
|
617
|
+
* error patterns or deduplicate repeated failures.
|
|
334
618
|
*
|
|
335
619
|
* @since 2.0.0
|
|
336
|
-
* @category
|
|
620
|
+
* @category Elements
|
|
337
621
|
*/
|
|
338
622
|
const contains = exports.contains = internal.contains;
|
|
339
623
|
/**
|
|
340
|
-
*
|
|
341
|
-
*
|
|
624
|
+
* Extracts the most "important" defect from a `Cause`.
|
|
625
|
+
*
|
|
626
|
+
* **Details**
|
|
627
|
+
*
|
|
628
|
+
* This function reduces a `Cause` to a single, prioritized defect. It evaluates
|
|
629
|
+
* the `Cause` in the following order of priority:
|
|
630
|
+
*
|
|
631
|
+
* 1. If the `Cause` contains a failure (e.g., from `Effect.fail`), it returns
|
|
632
|
+
* the raw error value.
|
|
633
|
+
* 2. If there is no failure, it looks for the first defect (e.g., from
|
|
634
|
+
* `Effect.die`).
|
|
635
|
+
* 3. If neither of the above is present, and the `Cause` stems from an
|
|
636
|
+
* interruption, it creates and returns an `InterruptedException`.
|
|
637
|
+
*
|
|
638
|
+
* This function ensures you can always extract a meaningful representation of
|
|
639
|
+
* the primary issue from a potentially complex `Cause` structure.
|
|
640
|
+
*
|
|
641
|
+
* **When to Use**
|
|
642
|
+
*
|
|
643
|
+
* Use this function when you need to extract the most relevant error or defect
|
|
644
|
+
* from a `Cause`, especially in scenarios where multiple errors or defects may
|
|
645
|
+
* be present. It's particularly useful for simplifying error reporting or
|
|
646
|
+
* logging.
|
|
647
|
+
*
|
|
648
|
+
* @see {@link squashWith} Allows transforming failures into defects when squashing.
|
|
342
649
|
*
|
|
343
650
|
* @since 2.0.0
|
|
344
|
-
* @category
|
|
651
|
+
* @category Destructors
|
|
345
652
|
*/
|
|
346
653
|
const squash = exports.squash = core.causeSquash;
|
|
347
654
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
655
|
+
* Extracts the most "important" defect from a `Cause`, transforming failures
|
|
656
|
+
* into defects using a provided function.
|
|
657
|
+
*
|
|
658
|
+
* **Details**
|
|
659
|
+
*
|
|
660
|
+
* This function reduces a `Cause` to a single, prioritized defect, while
|
|
661
|
+
* allowing you to transform recoverable failures into defects through a custom
|
|
662
|
+
* function. It processes the `Cause` in the following order:
|
|
663
|
+
*
|
|
664
|
+
* 1. If the `Cause` contains a failure (e.g., from `Effect.fail`), it applies
|
|
665
|
+
* the provided function `f` to the error to transform it into a defect.
|
|
666
|
+
* 2. If there is no failure, it looks for the first defect (e.g., from
|
|
667
|
+
* `Effect.die`) and returns it.
|
|
668
|
+
* 3. If neither is present and the `Cause` stems from an interruption, it
|
|
669
|
+
* returns an `InterruptedException`.
|
|
670
|
+
*
|
|
671
|
+
* This function is particularly useful when you need custom handling or
|
|
672
|
+
* transformation of errors while processing a `Cause`.
|
|
673
|
+
*
|
|
674
|
+
* @see {@link squash} Extracts the most "important" defect without transforming failures.
|
|
351
675
|
*
|
|
352
676
|
* @since 2.0.0
|
|
353
|
-
* @category
|
|
677
|
+
* @category Destructors
|
|
354
678
|
*/
|
|
355
679
|
const squashWith = exports.squashWith = core.causeSquashWith;
|
|
356
680
|
/**
|
|
357
|
-
*
|
|
358
|
-
*
|
|
681
|
+
* Searches a `Cause` using a partial function to extract information.
|
|
682
|
+
*
|
|
683
|
+
* **Details**
|
|
684
|
+
*
|
|
685
|
+
* This function allows you to search through a `Cause` using a custom partial
|
|
686
|
+
* function. The partial function is applied to the `Cause`, and if it matches,
|
|
687
|
+
* the result is returned wrapped in a `Some`. If no match is found, the result
|
|
688
|
+
* is `None`.
|
|
689
|
+
*
|
|
690
|
+
* This is particularly useful when you are only interested in specific types of
|
|
691
|
+
* errors, defects, or interruption causes within a potentially complex `Cause`
|
|
692
|
+
* structure. By leveraging a partial function, you can focus on extracting only
|
|
693
|
+
* the relevant information you care about.
|
|
694
|
+
*
|
|
695
|
+
* The partial function should return an `Option` indicating whether it matched
|
|
696
|
+
* and the value it extracted.
|
|
359
697
|
*
|
|
360
698
|
* @since 2.0.0
|
|
361
|
-
* @category
|
|
699
|
+
* @category Elements
|
|
362
700
|
*/
|
|
363
701
|
const find = exports.find = internal.find;
|
|
364
702
|
/**
|
|
365
|
-
*
|
|
703
|
+
* Preserves parts of a `Cause` that match a given predicate.
|
|
704
|
+
*
|
|
705
|
+
* **Details**
|
|
706
|
+
*
|
|
707
|
+
* This function allows you to retain only the parts of a `Cause` structure that
|
|
708
|
+
* match a specified predicate or refinement. Any parts of the `Cause` that do
|
|
709
|
+
* not match the provided condition are excluded from the result.
|
|
710
|
+
*
|
|
711
|
+
* You can use this function in two ways:
|
|
712
|
+
* - With a `Predicate`: A function that evaluates whether a `Cause` should be
|
|
713
|
+
* retained based on its value.
|
|
714
|
+
* - With a `Refinement`: A more specific predicate that can refine the type of
|
|
715
|
+
* the `Cause`.
|
|
716
|
+
*
|
|
717
|
+
* This is useful when you need to extract specific types of errors, defects, or
|
|
718
|
+
* interruptions from a `Cause` while discarding unrelated parts.
|
|
366
719
|
*
|
|
367
720
|
* @since 2.0.0
|
|
368
|
-
* @category
|
|
721
|
+
* @category Filtering
|
|
369
722
|
*/
|
|
370
723
|
const filter = exports.filter = internal.filter;
|
|
371
724
|
/**
|
|
372
|
-
*
|
|
725
|
+
* Transforms a `Cause` into a single value using custom handlers for each
|
|
726
|
+
* possible case.
|
|
727
|
+
*
|
|
728
|
+
* **Details**
|
|
729
|
+
*
|
|
730
|
+
* This function processes a `Cause` by applying a set of custom handlers to
|
|
731
|
+
* each possible type of cause: `Empty`, `Fail`, `Die`, `Interrupt`,
|
|
732
|
+
* `Sequential`, and `Parallel`. The result of this function is a single value
|
|
733
|
+
* of type `Z`. This function allows you to define exactly how to handle each
|
|
734
|
+
* part of a `Cause`, whether it's a failure, defect, interruption, or a
|
|
735
|
+
* combination of these.
|
|
736
|
+
*
|
|
737
|
+
* The options parameter provides handlers for:
|
|
738
|
+
* - `onEmpty`: Handles the case where the cause is `Empty`, meaning no errors
|
|
739
|
+
* occurred.
|
|
740
|
+
* - `onFail`: Processes a failure with an error of type `E`.
|
|
741
|
+
* - `onDie`: Processes a defect (unexpected error).
|
|
742
|
+
* - `onInterrupt`: Handles a fiber interruption, providing the `FiberId` of the
|
|
743
|
+
* interruption.
|
|
744
|
+
* - `onSequential`: Combines two sequential causes into a single value of type
|
|
745
|
+
* `Z`.
|
|
746
|
+
* - `onParallel`: Combines two parallel causes into a single value of type `Z`.
|
|
373
747
|
*
|
|
374
748
|
* @since 2.0.0
|
|
375
|
-
* @category
|
|
749
|
+
* @category Matching
|
|
376
750
|
*/
|
|
377
751
|
const match = exports.match = internal.match;
|
|
378
752
|
/**
|
|
379
|
-
*
|
|
380
|
-
*
|
|
753
|
+
* Combines all parts of a `Cause` into a single value by starting with an
|
|
754
|
+
* initial value.
|
|
755
|
+
*
|
|
756
|
+
* **Details**
|
|
757
|
+
*
|
|
758
|
+
* This function processes a `Cause` by starting with an initial value (`zero`)
|
|
759
|
+
* and applying a custom function (`pf`) to combine all elements of the `Cause`
|
|
760
|
+
* into a single result of type `Z`. The custom function determines how each
|
|
761
|
+
* part of the `Cause` contributes to the final result. The function can return
|
|
762
|
+
* an `Option` to either continue combining values or skip specific parts of the
|
|
763
|
+
* `Cause`.
|
|
764
|
+
*
|
|
765
|
+
* This function is useful for tasks such as:
|
|
766
|
+
* - Aggregating error messages from a `Cause` into a single string.
|
|
767
|
+
* - Summarizing the structure of a `Cause` into a simplified result.
|
|
768
|
+
* - Filtering or processing only specific parts of a `Cause`.
|
|
769
|
+
*
|
|
770
|
+
* The reduction proceeds in a top-down manner, visiting all nodes in the
|
|
771
|
+
* `Cause` structure. This gives you complete control over how each part of the
|
|
772
|
+
* `Cause` contributes to the final result.
|
|
381
773
|
*
|
|
382
774
|
* @since 2.0.0
|
|
383
|
-
* @category
|
|
775
|
+
* @category Reducing
|
|
384
776
|
*/
|
|
385
777
|
const reduce = exports.reduce = internal.reduce;
|
|
386
778
|
/**
|
|
387
|
-
*
|
|
388
|
-
*
|
|
779
|
+
* Combines all parts of a `Cause` into a single value using a custom reducer
|
|
780
|
+
* and a context.
|
|
781
|
+
*
|
|
782
|
+
* **Details**
|
|
783
|
+
*
|
|
784
|
+
* This function allows you to reduce a `Cause` into a single value of type `Z`
|
|
785
|
+
* using a custom `CauseReducer`. A `CauseReducer` provides methods to handle
|
|
786
|
+
* specific parts of the `Cause`, such as failures, defects, or interruptions.
|
|
787
|
+
* Additionally, this function provides access to a `context` value, which can
|
|
788
|
+
* be used to carry information or maintain state during the reduction process.
|
|
789
|
+
*
|
|
790
|
+
* This is particularly useful when the reduction process needs additional
|
|
791
|
+
* context or configuration, such as:
|
|
792
|
+
* - Aggregating error details with dynamic formatting.
|
|
793
|
+
* - Collecting logs or statistics about the `Cause`.
|
|
794
|
+
* - Performing stateful transformations based on the `context`.
|
|
795
|
+
*
|
|
796
|
+
* @see {@link reduce} To reduce a `Cause` without additional context.
|
|
389
797
|
*
|
|
390
798
|
* @since 2.0.0
|
|
391
|
-
* @category
|
|
799
|
+
* @category Reducing
|
|
392
800
|
*/
|
|
393
801
|
const reduceWithContext = exports.reduceWithContext = internal.reduceWithContext;
|
|
394
802
|
/**
|
|
395
|
-
*
|
|
803
|
+
* Creates an error that indicates a `Fiber` was interrupted.
|
|
804
|
+
*
|
|
805
|
+
* **Details**
|
|
806
|
+
*
|
|
807
|
+
* This function constructs an `InterruptedException` recognized by the Effect
|
|
808
|
+
* runtime. It is usually thrown or returned when a fiber's execution is
|
|
809
|
+
* interrupted by external events or by another fiber. This is particularly
|
|
810
|
+
* helpful in concurrent programs where fibers may halt each other before
|
|
811
|
+
* completion.
|
|
396
812
|
*
|
|
397
813
|
* @since 2.0.0
|
|
398
|
-
* @category
|
|
814
|
+
* @category Errors
|
|
399
815
|
*/
|
|
400
816
|
const InterruptedException = exports.InterruptedException = core.InterruptedException;
|
|
401
817
|
/**
|
|
402
|
-
*
|
|
403
|
-
* otherwise.
|
|
818
|
+
* Checks if a given unknown value is an `InterruptedException`.
|
|
404
819
|
*
|
|
405
820
|
* @since 2.0.0
|
|
406
|
-
* @category
|
|
821
|
+
* @category Guards
|
|
407
822
|
*/
|
|
408
823
|
const isInterruptedException = exports.isInterruptedException = core.isInterruptedException;
|
|
409
824
|
/**
|
|
410
|
-
*
|
|
411
|
-
*
|
|
825
|
+
* Creates an error indicating an invalid method argument.
|
|
826
|
+
*
|
|
827
|
+
* **Details**
|
|
828
|
+
*
|
|
829
|
+
* This function constructs an `IllegalArgumentException`. It is typically
|
|
830
|
+
* thrown or returned when an operation receives improper inputs, such as
|
|
831
|
+
* out-of-range values or invalid object states.
|
|
412
832
|
*
|
|
413
833
|
* @since 2.0.0
|
|
414
|
-
* @category
|
|
834
|
+
* @category Errors
|
|
415
835
|
*/
|
|
416
836
|
const IllegalArgumentException = exports.IllegalArgumentException = core.IllegalArgumentException;
|
|
417
837
|
/**
|
|
418
|
-
*
|
|
419
|
-
* otherwise.
|
|
838
|
+
* Checks if a given unknown value is an `IllegalArgumentException`.
|
|
420
839
|
*
|
|
421
840
|
* @since 2.0.0
|
|
422
|
-
* @category
|
|
841
|
+
* @category Guards
|
|
423
842
|
*/
|
|
424
843
|
const isIllegalArgumentException = exports.isIllegalArgumentException = core.isIllegalArgumentException;
|
|
425
844
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
845
|
+
* Creates an error indicating a missing element.
|
|
846
|
+
*
|
|
847
|
+
* **Details**
|
|
848
|
+
*
|
|
849
|
+
* This function constructs a `NoSuchElementException`. It helps you clearly
|
|
850
|
+
* communicate that a required element is unavailable.
|
|
428
851
|
*
|
|
429
852
|
* @since 2.0.0
|
|
430
|
-
* @category
|
|
853
|
+
* @category Errors
|
|
431
854
|
*/
|
|
432
855
|
const NoSuchElementException = exports.NoSuchElementException = core.NoSuchElementException;
|
|
433
856
|
/**
|
|
434
|
-
*
|
|
435
|
-
* otherwise.
|
|
857
|
+
* Checks if a given unknown value is a `NoSuchElementException`.
|
|
436
858
|
*
|
|
437
859
|
* @since 2.0.0
|
|
438
|
-
* @category
|
|
860
|
+
* @category Guards
|
|
439
861
|
*/
|
|
440
862
|
const isNoSuchElementException = exports.isNoSuchElementException = core.isNoSuchElementException;
|
|
441
863
|
/**
|
|
442
|
-
*
|
|
864
|
+
* Creates an error for general runtime errors.
|
|
865
|
+
*
|
|
866
|
+
* **Details**
|
|
867
|
+
*
|
|
868
|
+
* This function constructs a `RuntimeException`, for errors that occur at
|
|
869
|
+
* runtime but are not specifically typed or categorized as interruptions,
|
|
870
|
+
* missing elements, or invalid arguments. It helps unify a wide range of
|
|
871
|
+
* unexpected conditions under a single, recognizable error type.
|
|
443
872
|
*
|
|
444
873
|
* @since 2.0.0
|
|
445
|
-
* @category
|
|
874
|
+
* @category Errors
|
|
446
875
|
*/
|
|
447
876
|
const RuntimeException = exports.RuntimeException = core.RuntimeException;
|
|
448
877
|
/**
|
|
449
|
-
*
|
|
450
|
-
* otherwise.
|
|
878
|
+
* Checks if a given unknown value is a `RuntimeException`.
|
|
451
879
|
*
|
|
452
880
|
* @since 2.0.0
|
|
453
|
-
* @category
|
|
881
|
+
* @category Guards
|
|
454
882
|
*/
|
|
455
883
|
const isRuntimeException = exports.isRuntimeException = core.isRuntimeException;
|
|
456
884
|
/**
|
|
457
|
-
*
|
|
458
|
-
*
|
|
885
|
+
* Creates an error for operations that exceed their expected time.
|
|
886
|
+
*
|
|
887
|
+
* **Details**
|
|
888
|
+
*
|
|
889
|
+
* This function constructs a `TimeoutException`. It is typically used to signal
|
|
890
|
+
* that an operation or fiber did not complete within a designated time limit,
|
|
891
|
+
* allowing you to handle slow or hanging processes.
|
|
459
892
|
*
|
|
460
893
|
* @since 2.0.0
|
|
461
|
-
* @category
|
|
894
|
+
* @category Errors
|
|
462
895
|
*/
|
|
463
896
|
const TimeoutException = exports.TimeoutException = core.TimeoutException;
|
|
464
897
|
/**
|
|
@@ -490,52 +923,82 @@ const TimeoutException = exports.TimeoutException = core.TimeoutException;
|
|
|
490
923
|
* promises or external APIs.
|
|
491
924
|
*
|
|
492
925
|
* @since 2.0.0
|
|
493
|
-
* @category
|
|
926
|
+
* @category Errors
|
|
494
927
|
*/
|
|
495
928
|
const UnknownException = exports.UnknownException = core.UnknownException;
|
|
496
929
|
/**
|
|
497
|
-
*
|
|
498
|
-
* otherwise.
|
|
930
|
+
* Checks if a given unknown value is an `UnknownException`.
|
|
499
931
|
*
|
|
500
932
|
* @since 2.0.0
|
|
501
|
-
* @category
|
|
933
|
+
* @category Guards
|
|
502
934
|
*/
|
|
503
935
|
const isUnknownException = exports.isUnknownException = core.isUnknownException;
|
|
504
936
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
937
|
+
* Creates an error indicating resource capacity has been exceeded.
|
|
938
|
+
*
|
|
939
|
+
* **Details**
|
|
940
|
+
*
|
|
941
|
+
* This function constructs an `ExceededCapacityException`, signifying that an
|
|
942
|
+
* operation or resource usage surpassed established limits. This can be
|
|
943
|
+
* essential for concurrency or resource management situations, ensuring your
|
|
944
|
+
* application doesn't go beyond acceptable thresholds.
|
|
507
945
|
*
|
|
508
946
|
* @since 3.5.0
|
|
509
|
-
* @category
|
|
947
|
+
* @category Errors
|
|
510
948
|
*/
|
|
511
949
|
const ExceededCapacityException = exports.ExceededCapacityException = core.ExceededCapacityException;
|
|
512
950
|
/**
|
|
513
|
-
*
|
|
514
|
-
* otherwise.
|
|
951
|
+
* Checks if a given unknown value is an `ExceededCapacityException`.
|
|
515
952
|
*
|
|
516
953
|
* @since 3.5.0
|
|
517
|
-
* @category
|
|
954
|
+
* @category Guards
|
|
518
955
|
*/
|
|
519
956
|
const isExceededCapacityException = exports.isExceededCapacityException = core.isExceededCapacityException;
|
|
520
957
|
/**
|
|
521
|
-
*
|
|
958
|
+
* Converts a `Cause` into a human-readable string.
|
|
959
|
+
*
|
|
960
|
+
* **Details**
|
|
961
|
+
*
|
|
962
|
+
* This function pretty-prints the entire `Cause`, including any failures,
|
|
963
|
+
* defects, and interruptions. It can be especially helpful for logging,
|
|
964
|
+
* debugging, or displaying structured errors to users.
|
|
965
|
+
*
|
|
966
|
+
* You can optionally pass `options` to configure how the error cause is
|
|
967
|
+
* rendered. By default, it includes essential details of all errors in the
|
|
968
|
+
* `Cause`.
|
|
969
|
+
*
|
|
970
|
+
* @see {@link prettyErrors} Get a list of `PrettyError` objects instead of a single string.
|
|
522
971
|
*
|
|
523
972
|
* @since 2.0.0
|
|
524
|
-
* @category
|
|
973
|
+
* @category Formatting
|
|
525
974
|
*/
|
|
526
975
|
const pretty = exports.pretty = internal.pretty;
|
|
527
976
|
/**
|
|
528
|
-
* Returns
|
|
977
|
+
* Returns a list of prettified errors (`PrettyError`) from a `Cause`.
|
|
978
|
+
*
|
|
979
|
+
* **Details**
|
|
980
|
+
*
|
|
981
|
+
* This function inspects the entire `Cause` and produces an array of
|
|
982
|
+
* `PrettyError` objects. Each object may include additional metadata, such as a
|
|
983
|
+
* `Span`, to provide deeper insights into where and how the error occurred.
|
|
529
984
|
*
|
|
530
985
|
* @since 3.2.0
|
|
531
|
-
* @category
|
|
986
|
+
* @category Formatting
|
|
532
987
|
*/
|
|
533
988
|
const prettyErrors = exports.prettyErrors = internal.prettyErrors;
|
|
534
989
|
/**
|
|
535
|
-
*
|
|
990
|
+
* Retrieves the original, unproxied error instance from an error object.
|
|
991
|
+
*
|
|
992
|
+
* **Details**
|
|
993
|
+
*
|
|
994
|
+
* This function returns the underlying error object without any
|
|
995
|
+
* library-specific wrapping or proxying that might occur during error handling.
|
|
996
|
+
* This can be essential if you need direct access to the error's native
|
|
997
|
+
* properties, such as stack traces or custom data fields, for detailed
|
|
998
|
+
* debugging or integration with external systems.
|
|
536
999
|
*
|
|
537
1000
|
* @since 2.0.0
|
|
538
|
-
* @category
|
|
1001
|
+
* @category Errors
|
|
539
1002
|
*/
|
|
540
1003
|
const originalError = exports.originalError = core.originalInstance;
|
|
541
1004
|
//# sourceMappingURL=Cause.js.map
|