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/src/Cause.ts
CHANGED
|
@@ -40,124 +40,215 @@ import type { Span } from "./Tracer.js"
|
|
|
40
40
|
import type { Covariant, NoInfer } from "./Types.js"
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
+
* A unique symbol identifying the `Cause` type.
|
|
44
|
+
*
|
|
45
|
+
* **Details**
|
|
46
|
+
*
|
|
47
|
+
* This provides a symbol that helps identify instances of the `Cause` data
|
|
48
|
+
* type. This can be used for advanced operations such as refining types or
|
|
49
|
+
* building internal utilities that check whether an unknown value is a `Cause`.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link isCause} Check if a value is a `Cause`
|
|
43
52
|
* @since 2.0.0
|
|
44
|
-
* @category
|
|
53
|
+
* @category Symbols
|
|
45
54
|
*/
|
|
46
55
|
export const CauseTypeId: unique symbol = internal.CauseTypeId
|
|
47
56
|
|
|
48
57
|
/**
|
|
49
58
|
* @since 2.0.0
|
|
50
|
-
* @category
|
|
59
|
+
* @category Symbols
|
|
51
60
|
*/
|
|
52
61
|
export type CauseTypeId = typeof CauseTypeId
|
|
53
62
|
|
|
54
63
|
/**
|
|
64
|
+
* A unique symbol identifying the `RuntimeException` type.
|
|
65
|
+
*
|
|
66
|
+
* **Details**
|
|
67
|
+
*
|
|
68
|
+
* This provides a symbol that identifies a `RuntimeException`. This is
|
|
69
|
+
* typically used internally by the library to recognize checked exceptions that
|
|
70
|
+
* occur during runtime.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link RuntimeException} Create or work with a `RuntimeException`
|
|
73
|
+
*
|
|
55
74
|
* @since 2.0.0
|
|
56
|
-
* @category
|
|
75
|
+
* @category Symbols
|
|
57
76
|
*/
|
|
58
77
|
export const RuntimeExceptionTypeId: unique symbol = core.RuntimeExceptionTypeId
|
|
59
78
|
|
|
60
79
|
/**
|
|
61
80
|
* @since 2.0.0
|
|
62
|
-
* @category
|
|
81
|
+
* @category Symbols
|
|
63
82
|
*/
|
|
64
83
|
export type RuntimeExceptionTypeId = typeof RuntimeExceptionTypeId
|
|
65
84
|
|
|
66
85
|
/**
|
|
86
|
+
* A unique symbol identifying the `InterruptedException` type.
|
|
87
|
+
*
|
|
88
|
+
* **Details**
|
|
89
|
+
*
|
|
90
|
+
* This provides a symbol that identifies an `InterruptedException`. This is
|
|
91
|
+
* typically used internally to recognize when a fiber has been interrupted,
|
|
92
|
+
* helping the framework handle interruption logic correctly.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link InterruptedException} Create or work with an `InterruptedException`
|
|
95
|
+
*
|
|
67
96
|
* @since 2.0.0
|
|
68
|
-
* @category
|
|
97
|
+
* @category Symbols
|
|
69
98
|
*/
|
|
70
99
|
export const InterruptedExceptionTypeId: unique symbol = core.InterruptedExceptionTypeId
|
|
71
100
|
|
|
72
101
|
/**
|
|
73
102
|
* @since 2.0.0
|
|
74
|
-
* @category
|
|
103
|
+
* @category Symbols
|
|
75
104
|
*/
|
|
76
105
|
export type InterruptedExceptionTypeId = typeof InterruptedExceptionTypeId
|
|
77
106
|
|
|
78
107
|
/**
|
|
108
|
+
* A unique symbol identifying the `IllegalArgumentException` type.
|
|
109
|
+
*
|
|
110
|
+
* **Details**
|
|
111
|
+
*
|
|
112
|
+
* This provides a symbol that identifies an `IllegalArgumentException`. This is
|
|
113
|
+
* often used in scenarios where invalid arguments are supplied to methods that
|
|
114
|
+
* expect specific input.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link IllegalArgumentException} Create or work with an `IllegalArgumentException`
|
|
117
|
+
*
|
|
79
118
|
* @since 2.0.0
|
|
80
|
-
* @category
|
|
119
|
+
* @category Symbols
|
|
81
120
|
*/
|
|
82
121
|
export const IllegalArgumentExceptionTypeId: unique symbol = core.IllegalArgumentExceptionTypeId
|
|
83
122
|
|
|
84
123
|
/**
|
|
85
124
|
* @since 2.0.0
|
|
86
|
-
* @category
|
|
125
|
+
* @category Symbols
|
|
87
126
|
*/
|
|
88
127
|
export type IllegalArgumentExceptionTypeId = typeof IllegalArgumentExceptionTypeId
|
|
89
128
|
|
|
90
129
|
/**
|
|
130
|
+
* A unique symbol identifying the `NoSuchElementException` type.
|
|
131
|
+
*
|
|
132
|
+
* **Details**
|
|
133
|
+
*
|
|
134
|
+
* This provides a symbol that identifies a `NoSuchElementException`. It helps
|
|
135
|
+
* differentiate cases where a required element is missing within a data
|
|
136
|
+
* structure.
|
|
137
|
+
*
|
|
138
|
+
* @see {@link NoSuchElementException} Create or work with a `NoSuchElementException`
|
|
139
|
+
*
|
|
91
140
|
* @since 2.0.0
|
|
92
|
-
* @category
|
|
141
|
+
* @category Symbols
|
|
93
142
|
*/
|
|
94
143
|
export const NoSuchElementExceptionTypeId: unique symbol = core.NoSuchElementExceptionTypeId
|
|
95
144
|
|
|
96
145
|
/**
|
|
97
146
|
* @since 2.0.0
|
|
98
|
-
* @category
|
|
147
|
+
* @category Symbols
|
|
99
148
|
*/
|
|
100
149
|
export type NoSuchElementExceptionTypeId = typeof NoSuchElementExceptionTypeId
|
|
101
150
|
|
|
102
151
|
/**
|
|
152
|
+
* A unique symbol identifying the `InvalidPubSubCapacityException` type.
|
|
153
|
+
*
|
|
154
|
+
* **Details**
|
|
155
|
+
*
|
|
156
|
+
* This provides a symbol that identifies an `InvalidPubSubCapacityException`.
|
|
157
|
+
* It indicates an error related to an invalid capacity passed to a `PubSub`
|
|
158
|
+
* structure.
|
|
159
|
+
*
|
|
160
|
+
* @see {@link InvalidPubSubCapacityException} Create or work with an `InvalidPubSubCapacityException`
|
|
161
|
+
*
|
|
103
162
|
* @since 2.0.0
|
|
104
|
-
* @category
|
|
163
|
+
* @category Symbols
|
|
105
164
|
*/
|
|
106
165
|
export const InvalidPubSubCapacityExceptionTypeId: unique symbol = core.InvalidPubSubCapacityExceptionTypeId
|
|
107
166
|
|
|
108
167
|
/**
|
|
109
168
|
* @since 2.0.0
|
|
110
|
-
* @category
|
|
169
|
+
* @category Symbols
|
|
111
170
|
*/
|
|
112
171
|
export type InvalidPubSubCapacityExceptionTypeId = typeof InvalidPubSubCapacityExceptionTypeId
|
|
113
172
|
|
|
114
173
|
/**
|
|
174
|
+
* A unique symbol identifying the `ExceededCapacityException` type.
|
|
175
|
+
*
|
|
176
|
+
* **Details**
|
|
177
|
+
*
|
|
178
|
+
* This provides a symbol that identifies an `ExceededCapacityException`. It
|
|
179
|
+
* denotes situations where a resource has exceeded its configured capacity
|
|
180
|
+
* limit.
|
|
181
|
+
*
|
|
182
|
+
* @see {@link ExceededCapacityException} Create or work with an `ExceededCapacityException`
|
|
183
|
+
*
|
|
115
184
|
* @since 3.5.0
|
|
116
|
-
* @category
|
|
185
|
+
* @category Symbols
|
|
117
186
|
*/
|
|
118
187
|
export const ExceededCapacityExceptionTypeId: unique symbol = core.ExceededCapacityExceptionTypeId
|
|
119
188
|
|
|
120
189
|
/**
|
|
121
190
|
* @since 3.5.0
|
|
122
|
-
* @category
|
|
191
|
+
* @category Symbols
|
|
123
192
|
*/
|
|
124
193
|
export type ExceededCapacityExceptionTypeId = typeof ExceededCapacityExceptionTypeId
|
|
125
194
|
|
|
126
195
|
/**
|
|
196
|
+
* A unique symbol identifying the `TimeoutException` type.
|
|
197
|
+
*
|
|
198
|
+
* **Details**
|
|
199
|
+
*
|
|
200
|
+
* This provides a symbol that identifies a `TimeoutException`. It helps the
|
|
201
|
+
* framework recognize errors related to operations that fail to complete within
|
|
202
|
+
* a given timeframe.
|
|
203
|
+
*
|
|
204
|
+
* @see {@link TimeoutException} Create or work with a `TimeoutException`
|
|
205
|
+
*
|
|
127
206
|
* @since 2.0.0
|
|
128
|
-
* @category
|
|
207
|
+
* @category Symbols
|
|
129
208
|
*/
|
|
130
209
|
export const TimeoutExceptionTypeId: unique symbol = core.TimeoutExceptionTypeId
|
|
131
210
|
|
|
132
211
|
/**
|
|
133
212
|
* @since 2.0.0
|
|
134
|
-
* @category
|
|
213
|
+
* @category Symbols
|
|
135
214
|
*/
|
|
136
215
|
export type TimeoutExceptionTypeId = typeof TimeoutExceptionTypeId
|
|
137
216
|
|
|
138
217
|
/**
|
|
218
|
+
* A unique symbol identifying the `UnknownException` type.
|
|
219
|
+
*
|
|
220
|
+
* **Details**
|
|
221
|
+
*
|
|
222
|
+
* This provides a symbol that identifies an `UnknownException`. It is typically
|
|
223
|
+
* used for generic or unexpected errors that do not fit other specific
|
|
224
|
+
* exception categories.
|
|
225
|
+
*
|
|
226
|
+
* @see {@link UnknownException} Create or work with an `UnknownException`
|
|
227
|
+
*
|
|
139
228
|
* @since 2.0.0
|
|
140
|
-
* @category
|
|
229
|
+
* @category Symbols
|
|
141
230
|
*/
|
|
142
231
|
export const UnknownExceptionTypeId: unique symbol = core.UnknownExceptionTypeId
|
|
143
232
|
|
|
144
233
|
/**
|
|
145
234
|
* @since 2.0.0
|
|
146
|
-
* @category
|
|
235
|
+
* @category Symbols
|
|
147
236
|
*/
|
|
148
237
|
export type UnknownExceptionTypeId = typeof UnknownExceptionTypeId
|
|
149
238
|
|
|
150
239
|
/**
|
|
151
|
-
*
|
|
152
|
-
* `Effect` workflow.
|
|
240
|
+
* Represents the full history of a failure within an `Effect`.
|
|
153
241
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
242
|
+
* **Details**
|
|
243
|
+
*
|
|
244
|
+
* This type is a data structure that captures all information about why and how
|
|
245
|
+
* an effect has failed, including parallel errors, sequential errors, defects,
|
|
246
|
+
* and interruptions. It enables a "lossless" error model: no error-related
|
|
247
|
+
* information is discarded, which helps in debugging and understanding the root
|
|
248
|
+
* cause of failures.
|
|
158
249
|
*
|
|
159
250
|
* @since 2.0.0
|
|
160
|
-
* @category
|
|
251
|
+
* @category Models
|
|
161
252
|
*/
|
|
162
253
|
export type Cause<E> =
|
|
163
254
|
| Empty
|
|
@@ -172,8 +263,10 @@ export type Cause<E> =
|
|
|
172
263
|
*/
|
|
173
264
|
export declare namespace Cause {
|
|
174
265
|
/**
|
|
266
|
+
* This interface is used internally to manage the type variance of `Cause`.
|
|
267
|
+
*
|
|
175
268
|
* @since 2.0.0
|
|
176
|
-
* @category
|
|
269
|
+
* @category Models
|
|
177
270
|
*/
|
|
178
271
|
export interface Variance<out E> {
|
|
179
272
|
readonly [CauseTypeId]: {
|
|
@@ -183,11 +276,21 @@ export declare namespace Cause {
|
|
|
183
276
|
}
|
|
184
277
|
|
|
185
278
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
279
|
+
* Describes methods for reducing a `Cause<E>` into a value of type `Z` with
|
|
280
|
+
* access to contextual information.
|
|
281
|
+
*
|
|
282
|
+
* **Details**
|
|
283
|
+
*
|
|
284
|
+
* This interface is meant for advanced transformations of `Cause`. By
|
|
285
|
+
* implementing each method, you can define how different parts of the `Cause`
|
|
286
|
+
* structure (like `Fail`, `Die`, or `Interrupt`) should be transformed into a
|
|
287
|
+
* final type `Z`. The `context` parameter carries additional data needed during
|
|
288
|
+
* this reduction.
|
|
289
|
+
*
|
|
290
|
+
* @see {@link reduceWithContext} Apply a `CauseReducer` to transform a `Cause`
|
|
188
291
|
*
|
|
189
292
|
* @since 2.0.0
|
|
190
|
-
* @category
|
|
293
|
+
* @category Models
|
|
191
294
|
*/
|
|
192
295
|
export interface CauseReducer<in C, in E, in out Z> {
|
|
193
296
|
emptyCase(context: C): Z
|
|
@@ -199,8 +302,10 @@ export interface CauseReducer<in C, in E, in out Z> {
|
|
|
199
302
|
}
|
|
200
303
|
|
|
201
304
|
/**
|
|
305
|
+
* Represents an error object that can be yielded in `Effect.gen`.
|
|
306
|
+
*
|
|
202
307
|
* @since 2.0.0
|
|
203
|
-
* @category
|
|
308
|
+
* @category Models
|
|
204
309
|
*/
|
|
205
310
|
export interface YieldableError extends Pipeable, Inspectable, Readonly<Error> {
|
|
206
311
|
readonly [Effect.EffectTypeId]: Effect.Effect.VarianceStruct<never, this, never>
|
|
@@ -211,18 +316,24 @@ export interface YieldableError extends Pipeable, Inspectable, Readonly<Error> {
|
|
|
211
316
|
}
|
|
212
317
|
|
|
213
318
|
/**
|
|
214
|
-
*
|
|
319
|
+
* Creates an error that occurs at runtime, extendable for other exception
|
|
320
|
+
* types.
|
|
215
321
|
*
|
|
216
322
|
* @since 2.0.0
|
|
217
|
-
* @category
|
|
323
|
+
* @category Errors
|
|
218
324
|
*/
|
|
219
325
|
export const YieldableError: new(message?: string | undefined) => YieldableError = core.YieldableError
|
|
220
326
|
|
|
221
327
|
/**
|
|
222
|
-
*
|
|
328
|
+
* An error representing a runtime error.
|
|
329
|
+
*
|
|
330
|
+
* **Details**
|
|
331
|
+
*
|
|
332
|
+
* This interface is used for errors that occur at runtime but are still
|
|
333
|
+
* considered recoverable or typed.
|
|
223
334
|
*
|
|
224
335
|
* @since 2.0.0
|
|
225
|
-
* @category
|
|
336
|
+
* @category Models
|
|
226
337
|
*/
|
|
227
338
|
export interface RuntimeException extends YieldableError {
|
|
228
339
|
readonly _tag: "RuntimeException"
|
|
@@ -230,10 +341,17 @@ export interface RuntimeException extends YieldableError {
|
|
|
230
341
|
}
|
|
231
342
|
|
|
232
343
|
/**
|
|
233
|
-
*
|
|
344
|
+
* An error representing fiber interruption.
|
|
345
|
+
*
|
|
346
|
+
* **Details**
|
|
347
|
+
*
|
|
348
|
+
* This interface represents errors that occur when a fiber is forcefully
|
|
349
|
+
* interrupted. Interruption can happen for various reasons, including
|
|
350
|
+
* cancellations or system directives to halt operations. Code that deals with
|
|
351
|
+
* concurrency might need to catch or handle these to ensure proper cleanup.
|
|
234
352
|
*
|
|
235
353
|
* @since 2.0.0
|
|
236
|
-
* @category
|
|
354
|
+
* @category Models
|
|
237
355
|
*/
|
|
238
356
|
export interface InterruptedException extends YieldableError {
|
|
239
357
|
readonly _tag: "InterruptedException"
|
|
@@ -241,11 +359,15 @@ export interface InterruptedException extends YieldableError {
|
|
|
241
359
|
}
|
|
242
360
|
|
|
243
361
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
362
|
+
* An error representing an invalid argument passed to a method.
|
|
363
|
+
*
|
|
364
|
+
* **Details**
|
|
365
|
+
*
|
|
366
|
+
* This interface is used for signaling that a function or method received an
|
|
367
|
+
* argument that does not meet its preconditions.
|
|
246
368
|
*
|
|
247
369
|
* @since 2.0.0
|
|
248
|
-
* @category
|
|
370
|
+
* @category Models
|
|
249
371
|
*/
|
|
250
372
|
export interface IllegalArgumentException extends YieldableError {
|
|
251
373
|
readonly _tag: "IllegalArgumentException"
|
|
@@ -253,11 +375,16 @@ export interface IllegalArgumentException extends YieldableError {
|
|
|
253
375
|
}
|
|
254
376
|
|
|
255
377
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
378
|
+
* An error that occurs when an expected element is missing.
|
|
379
|
+
*
|
|
380
|
+
* **Details**
|
|
381
|
+
*
|
|
382
|
+
* This interface indicates scenarios like looking up an item in a collection
|
|
383
|
+
* or searching for data that should be present but isn't. It helps your code
|
|
384
|
+
* signal a more specific issue rather than a general error.
|
|
258
385
|
*
|
|
259
386
|
* @since 2.0.0
|
|
260
|
-
* @category
|
|
387
|
+
* @category Models
|
|
261
388
|
*/
|
|
262
389
|
export interface NoSuchElementException extends YieldableError {
|
|
263
390
|
readonly _tag: "NoSuchElementException"
|
|
@@ -265,11 +392,10 @@ export interface NoSuchElementException extends YieldableError {
|
|
|
265
392
|
}
|
|
266
393
|
|
|
267
394
|
/**
|
|
268
|
-
*
|
|
269
|
-
* `PubSub` with an invalid capacity.
|
|
395
|
+
* An error indicating invalid capacity for a `PubSub`.
|
|
270
396
|
*
|
|
271
397
|
* @since 2.0.0
|
|
272
|
-
* @category
|
|
398
|
+
* @category Models
|
|
273
399
|
*/
|
|
274
400
|
export interface InvalidPubSubCapacityException extends YieldableError {
|
|
275
401
|
readonly _tag: "InvalidPubSubCapacityException"
|
|
@@ -277,11 +403,10 @@ export interface InvalidPubSubCapacityException extends YieldableError {
|
|
|
277
403
|
}
|
|
278
404
|
|
|
279
405
|
/**
|
|
280
|
-
*
|
|
281
|
-
* been exceeded.
|
|
406
|
+
* An error that occurs when resource capacity is exceeded.
|
|
282
407
|
*
|
|
283
408
|
* @since 3.5.0
|
|
284
|
-
* @category
|
|
409
|
+
* @category Models
|
|
285
410
|
*/
|
|
286
411
|
export interface ExceededCapacityException extends YieldableError {
|
|
287
412
|
readonly _tag: "ExceededCapacityException"
|
|
@@ -289,11 +414,10 @@ export interface ExceededCapacityException extends YieldableError {
|
|
|
289
414
|
}
|
|
290
415
|
|
|
291
416
|
/**
|
|
292
|
-
*
|
|
293
|
-
* finish on schedule.
|
|
417
|
+
* An error representing a computation that timed out.
|
|
294
418
|
*
|
|
295
419
|
* @since 2.0.0
|
|
296
|
-
* @category
|
|
420
|
+
* @category Models
|
|
297
421
|
*/
|
|
298
422
|
export interface TimeoutException extends YieldableError {
|
|
299
423
|
readonly _tag: "TimeoutException"
|
|
@@ -301,11 +425,16 @@ export interface TimeoutException extends YieldableError {
|
|
|
301
425
|
}
|
|
302
426
|
|
|
303
427
|
/**
|
|
304
|
-
*
|
|
305
|
-
*
|
|
428
|
+
* A checked exception for handling unknown or unexpected errors.
|
|
429
|
+
*
|
|
430
|
+
* **Details**
|
|
431
|
+
*
|
|
432
|
+
* This interface captures errors that don't fall under known categories. It is
|
|
433
|
+
* especially helpful for wrapping low-level or third-party library errors that
|
|
434
|
+
* might provide little or no context, such as from a rejected promise.
|
|
306
435
|
*
|
|
307
436
|
* @since 2.0.0
|
|
308
|
-
* @category
|
|
437
|
+
* @category Models
|
|
309
438
|
*/
|
|
310
439
|
export interface UnknownException extends YieldableError {
|
|
311
440
|
readonly _tag: "UnknownException"
|
|
@@ -314,21 +443,32 @@ export interface UnknownException extends YieldableError {
|
|
|
314
443
|
}
|
|
315
444
|
|
|
316
445
|
/**
|
|
317
|
-
*
|
|
446
|
+
* Represents a lack of errors within a `Cause`.
|
|
447
|
+
*
|
|
448
|
+
* @see {@link empty} Construct a new `Empty` cause
|
|
449
|
+
* @see {@link isEmptyType} Check if a `Cause` is an `Empty` type
|
|
318
450
|
*
|
|
319
451
|
* @since 2.0.0
|
|
320
|
-
* @category
|
|
452
|
+
* @category Models
|
|
321
453
|
*/
|
|
322
454
|
export interface Empty extends Cause.Variance<never>, Equal.Equal, Pipeable, Inspectable {
|
|
323
455
|
readonly _tag: "Empty"
|
|
324
456
|
}
|
|
325
457
|
|
|
326
458
|
/**
|
|
327
|
-
*
|
|
328
|
-
*
|
|
459
|
+
* Represents an expected error within a `Cause`.
|
|
460
|
+
*
|
|
461
|
+
* **Details**
|
|
462
|
+
*
|
|
463
|
+
* This interface models a `Cause` that carries an expected or known error of
|
|
464
|
+
* type `E`. For example, if you validate user input and find it invalid, you
|
|
465
|
+
* might store that error within a `Fail`.
|
|
466
|
+
*
|
|
467
|
+
* @see {@link fail} Construct a `Fail` cause
|
|
468
|
+
* @see {@link isFailType} Check if a `Cause` is a `Fail`
|
|
329
469
|
*
|
|
330
470
|
* @since 2.0.0
|
|
331
|
-
* @category
|
|
471
|
+
* @category Models
|
|
332
472
|
*/
|
|
333
473
|
export interface Fail<out E> extends Cause.Variance<E>, Equal.Equal, Pipeable, Inspectable {
|
|
334
474
|
readonly _tag: "Fail"
|
|
@@ -336,12 +476,19 @@ export interface Fail<out E> extends Cause.Variance<E>, Equal.Equal, Pipeable, I
|
|
|
336
476
|
}
|
|
337
477
|
|
|
338
478
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
479
|
+
* Represents an unexpected defect within a `Cause`.
|
|
480
|
+
*
|
|
481
|
+
* **Details**
|
|
482
|
+
*
|
|
483
|
+
* This interface models a `Cause` for errors that are typically unrecoverable or
|
|
484
|
+
* unanticipated—like runtime exceptions or bugs. When code "dies," it indicates a
|
|
485
|
+
* severe failure that wasn't accounted for.
|
|
486
|
+
*
|
|
487
|
+
* @see {@link die} Construct a `Die` cause
|
|
488
|
+
* @see {@link isDieType} Check if a `Cause` is a `Die`
|
|
341
489
|
*
|
|
342
|
-
* type `E`.
|
|
343
490
|
* @since 2.0.0
|
|
344
|
-
* @category
|
|
491
|
+
* @category Models
|
|
345
492
|
*/
|
|
346
493
|
export interface Die extends Cause.Variance<never>, Equal.Equal, Pipeable, Inspectable {
|
|
347
494
|
readonly _tag: "Die"
|
|
@@ -349,11 +496,20 @@ export interface Die extends Cause.Variance<never>, Equal.Equal, Pipeable, Inspe
|
|
|
349
496
|
}
|
|
350
497
|
|
|
351
498
|
/**
|
|
352
|
-
*
|
|
353
|
-
*
|
|
499
|
+
* Represents fiber interruption within a `Cause`.
|
|
500
|
+
*
|
|
501
|
+
* **Details**
|
|
502
|
+
*
|
|
503
|
+
* This interface models a scenario where an effect was halted by an external
|
|
504
|
+
* signal, carrying a `FiberId` that identifies which fiber was interrupted.
|
|
505
|
+
* Interruption is a normal part of concurrency, used for cancellation or
|
|
506
|
+
* resource cleanup.
|
|
507
|
+
*
|
|
508
|
+
* @see {@link interrupt} Construct an `Interrupt` cause
|
|
509
|
+
* @see {@link isInterruptType} Check if a `Cause` is an `Interrupt`
|
|
354
510
|
*
|
|
355
511
|
* @since 2.0.0
|
|
356
|
-
* @category
|
|
512
|
+
* @category Models
|
|
357
513
|
*/
|
|
358
514
|
export interface Interrupt extends Cause.Variance<never>, Equal.Equal, Pipeable, Inspectable {
|
|
359
515
|
readonly _tag: "Interrupt"
|
|
@@ -361,17 +517,19 @@ export interface Interrupt extends Cause.Variance<never>, Equal.Equal, Pipeable,
|
|
|
361
517
|
}
|
|
362
518
|
|
|
363
519
|
/**
|
|
364
|
-
*
|
|
365
|
-
*
|
|
520
|
+
* Represents parallel composition of two `Cause`s.
|
|
521
|
+
*
|
|
522
|
+
* **Details**
|
|
523
|
+
*
|
|
524
|
+
* This interface captures failures that happen simultaneously. In scenarios
|
|
525
|
+
* with concurrency, more than one operation can fail in parallel. Instead of
|
|
526
|
+
* losing information, this structure stores both errors together.
|
|
366
527
|
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
* reason. If both computations fail, then there are actually two errors which
|
|
370
|
-
* occurred in parallel. In these cases, the errors can be represented by the
|
|
371
|
-
* `Parallel` cause.
|
|
528
|
+
* @see {@link parallel} Combine two `Cause`s in parallel
|
|
529
|
+
* @see {@link isParallelType} Check if a `Cause` is a `Parallel`
|
|
372
530
|
*
|
|
373
531
|
* @since 2.0.0
|
|
374
|
-
* @category
|
|
532
|
+
* @category Models
|
|
375
533
|
*/
|
|
376
534
|
export interface Parallel<out E> extends Cause.Variance<E>, Equal.Equal, Pipeable, Inspectable {
|
|
377
535
|
readonly _tag: "Parallel"
|
|
@@ -380,16 +538,19 @@ export interface Parallel<out E> extends Cause.Variance<E>, Equal.Equal, Pipeabl
|
|
|
380
538
|
}
|
|
381
539
|
|
|
382
540
|
/**
|
|
383
|
-
*
|
|
384
|
-
* sequentially.
|
|
541
|
+
* Represents sequential composition of two `Cause`s.
|
|
385
542
|
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
543
|
+
* **Details**
|
|
544
|
+
*
|
|
545
|
+
* This interface models the scenario where one error follows another in
|
|
546
|
+
* sequence, such as when a main effect fails and then a finalizer also fails.
|
|
547
|
+
* It ensures both errors are retained in the final `Cause`.
|
|
548
|
+
*
|
|
549
|
+
* @see {@link sequential} Combine two `Cause`s sequentially
|
|
550
|
+
* @see {@link isSequentialType} Check if a `Cause` is a `Sequential`
|
|
390
551
|
*
|
|
391
552
|
* @since 2.0.0
|
|
392
|
-
* @category
|
|
553
|
+
* @category Models
|
|
393
554
|
*/
|
|
394
555
|
export interface Sequential<out E> extends Cause.Variance<E>, Equal.Equal, Pipeable, Inspectable {
|
|
395
556
|
readonly _tag: "Sequential"
|
|
@@ -398,529 +559,1042 @@ export interface Sequential<out E> extends Cause.Variance<E>, Equal.Equal, Pipea
|
|
|
398
559
|
}
|
|
399
560
|
|
|
400
561
|
/**
|
|
401
|
-
*
|
|
562
|
+
* Creates an `Empty` cause.
|
|
563
|
+
*
|
|
564
|
+
* **Details**
|
|
565
|
+
*
|
|
566
|
+
* This function returns a cause that signifies "no error." It's commonly used
|
|
567
|
+
* to represent an absence of failure conditions.
|
|
568
|
+
*
|
|
569
|
+
* @see {@link isEmpty} Check if a `Cause` is empty
|
|
402
570
|
*
|
|
403
571
|
* @since 2.0.0
|
|
404
|
-
* @category
|
|
572
|
+
* @category Constructors
|
|
405
573
|
*/
|
|
406
574
|
export const empty: Cause<never> = internal.empty
|
|
407
575
|
|
|
408
576
|
/**
|
|
409
|
-
*
|
|
577
|
+
* Creates a `Fail` cause from an expected error.
|
|
578
|
+
*
|
|
579
|
+
* **Details**
|
|
580
|
+
*
|
|
581
|
+
* This function constructs a `Cause` carrying an error of type `E`. It's used
|
|
582
|
+
* when you want to represent a known or anticipated failure in your effectful
|
|
583
|
+
* computations.
|
|
584
|
+
*
|
|
585
|
+
* @see {@link isFailure} Check if a `Cause` contains a failure
|
|
410
586
|
*
|
|
411
587
|
* @since 2.0.0
|
|
412
|
-
* @category
|
|
588
|
+
* @category Constructors
|
|
413
589
|
*/
|
|
414
590
|
export const fail: <E>(error: E) => Cause<E> = internal.fail
|
|
415
591
|
|
|
416
592
|
/**
|
|
417
|
-
*
|
|
593
|
+
* Creates a `Die` cause from an unexpected error.
|
|
594
|
+
*
|
|
595
|
+
* **Details**
|
|
596
|
+
*
|
|
597
|
+
* This function wraps an unhandled or unknown defect (like a runtime crash)
|
|
598
|
+
* into a `Cause`. It's useful for capturing unforeseen issues in a structured
|
|
599
|
+
* way.
|
|
600
|
+
*
|
|
601
|
+
* @see {@link isDie} Check if a `Cause` contains a defect
|
|
418
602
|
*
|
|
419
603
|
* @since 2.0.0
|
|
420
|
-
* @category
|
|
604
|
+
* @category Constructors
|
|
421
605
|
*/
|
|
422
606
|
export const die: (defect: unknown) => Cause<never> = internal.die
|
|
423
607
|
|
|
424
608
|
/**
|
|
425
|
-
*
|
|
609
|
+
* Creates an `Interrupt` cause from a `FiberId`.
|
|
610
|
+
*
|
|
611
|
+
* **Details**
|
|
612
|
+
*
|
|
613
|
+
* This function represents a fiber that has been interrupted. It stores the
|
|
614
|
+
* identifier of the interrupted fiber, enabling precise tracking of concurrent
|
|
615
|
+
* cancellations.
|
|
616
|
+
*
|
|
617
|
+
* @see {@link isInterrupted} Check if a `Cause` contains an interruption
|
|
426
618
|
*
|
|
427
619
|
* @since 2.0.0
|
|
428
|
-
* @category
|
|
620
|
+
* @category Constructors
|
|
429
621
|
*/
|
|
430
622
|
export const interrupt: (fiberId: FiberId.FiberId) => Cause<never> = internal.interrupt
|
|
431
623
|
|
|
432
624
|
/**
|
|
433
|
-
*
|
|
434
|
-
*
|
|
625
|
+
* Combines two `Cause`s in parallel.
|
|
626
|
+
*
|
|
627
|
+
* **Details**
|
|
628
|
+
*
|
|
629
|
+
* This function merges two errors that occurred simultaneously. Instead of
|
|
630
|
+
* discarding one error, both are retained, allowing for richer error reporting
|
|
631
|
+
* and debugging.
|
|
632
|
+
*
|
|
633
|
+
* @see {@link isParallelType} Check if a `Cause` is a `Parallel`
|
|
435
634
|
*
|
|
436
635
|
* @since 2.0.0
|
|
437
|
-
* @category
|
|
636
|
+
* @category Constructors
|
|
438
637
|
*/
|
|
439
638
|
export const parallel: <E, E2>(left: Cause<E>, right: Cause<E2>) => Cause<E | E2> = internal.parallel
|
|
440
639
|
|
|
441
640
|
/**
|
|
442
|
-
*
|
|
443
|
-
*
|
|
641
|
+
* Combines two `Cause`s sequentially.
|
|
642
|
+
*
|
|
643
|
+
* **Details**
|
|
644
|
+
*
|
|
645
|
+
* This function merges two errors that occurred in sequence, such as a main
|
|
646
|
+
* error followed by a finalization error. It preserves both errors for complete
|
|
647
|
+
* failure information.
|
|
648
|
+
*
|
|
649
|
+
* @see {@link isSequentialType} Check if a `Cause` is a `Sequential`
|
|
444
650
|
*
|
|
445
651
|
* @since 2.0.0
|
|
446
|
-
* @category
|
|
652
|
+
* @category Constructors
|
|
447
653
|
*/
|
|
448
654
|
export const sequential: <E, E2>(left: Cause<E>, right: Cause<E2>) => Cause<E | E2> = internal.sequential
|
|
449
655
|
|
|
450
656
|
/**
|
|
451
|
-
*
|
|
657
|
+
* Checks if a value is a `Cause`.
|
|
452
658
|
*
|
|
453
659
|
* @since 2.0.0
|
|
454
|
-
* @category
|
|
660
|
+
* @category Guards
|
|
455
661
|
*/
|
|
456
662
|
export const isCause: (u: unknown) => u is Cause<unknown> = internal.isCause
|
|
457
663
|
|
|
458
664
|
/**
|
|
459
|
-
*
|
|
460
|
-
*
|
|
665
|
+
* Checks if a `Cause` is an `Empty` type.
|
|
666
|
+
*
|
|
667
|
+
* @see {@link empty} Create a new `Empty` cause
|
|
461
668
|
*
|
|
462
669
|
* @since 2.0.0
|
|
463
|
-
* @category
|
|
670
|
+
* @category Guards
|
|
464
671
|
*/
|
|
465
672
|
export const isEmptyType: <E>(self: Cause<E>) => self is Empty = internal.isEmptyType
|
|
466
673
|
|
|
467
674
|
/**
|
|
468
|
-
*
|
|
469
|
-
*
|
|
675
|
+
* Checks if a `Cause` is a `Fail` type.
|
|
676
|
+
*
|
|
677
|
+
* @see {@link fail} Create a new `Fail` cause
|
|
470
678
|
*
|
|
471
679
|
* @since 2.0.0
|
|
472
|
-
* @category
|
|
680
|
+
* @category Guards
|
|
473
681
|
*/
|
|
474
682
|
export const isFailType: <E>(self: Cause<E>) => self is Fail<E> = internal.isFailType
|
|
475
683
|
|
|
476
684
|
/**
|
|
477
|
-
*
|
|
478
|
-
*
|
|
685
|
+
* Checks if a `Cause` is a `Die` type.
|
|
686
|
+
*
|
|
687
|
+
* @see {@link die} Create a new `Die` cause
|
|
479
688
|
*
|
|
480
689
|
* @since 2.0.0
|
|
481
|
-
* @category
|
|
690
|
+
* @category Guards
|
|
482
691
|
*/
|
|
483
692
|
export const isDieType: <E>(self: Cause<E>) => self is Die = internal.isDieType
|
|
484
693
|
|
|
485
694
|
/**
|
|
486
|
-
*
|
|
487
|
-
*
|
|
695
|
+
* Checks if a `Cause` is an `Interrupt` type.
|
|
696
|
+
*
|
|
697
|
+
* @see {@link interrupt} Create an `Interrupt` cause
|
|
488
698
|
*
|
|
489
699
|
* @since 2.0.0
|
|
490
|
-
* @category
|
|
700
|
+
* @category Guards
|
|
491
701
|
*/
|
|
492
702
|
export const isInterruptType: <E>(self: Cause<E>) => self is Interrupt = internal.isInterruptType
|
|
493
703
|
|
|
494
704
|
/**
|
|
495
|
-
*
|
|
496
|
-
*
|
|
705
|
+
* Checks if a `Cause` is a `Sequential` type.
|
|
706
|
+
*
|
|
707
|
+
* @see {@link sequential} Combine two `Cause`s sequentially
|
|
497
708
|
*
|
|
498
709
|
* @since 2.0.0
|
|
499
|
-
* @category
|
|
710
|
+
* @category Guards
|
|
500
711
|
*/
|
|
501
712
|
export const isSequentialType: <E>(self: Cause<E>) => self is Sequential<E> = internal.isSequentialType
|
|
502
713
|
|
|
503
714
|
/**
|
|
504
|
-
*
|
|
505
|
-
*
|
|
715
|
+
* Checks if a `Cause` is a `Parallel` type.
|
|
716
|
+
*
|
|
717
|
+
* @see {@link parallel} Combine two `Cause`s in parallel
|
|
506
718
|
*
|
|
507
719
|
* @since 2.0.0
|
|
508
|
-
* @category
|
|
720
|
+
* @category Guards
|
|
509
721
|
*/
|
|
510
722
|
export const isParallelType: <E>(self: Cause<E>) => self is Parallel<E> = internal.isParallelType
|
|
511
723
|
|
|
512
724
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
725
|
+
* Calculates the size of a `Cause`.
|
|
726
|
+
*
|
|
727
|
+
* **Details**
|
|
728
|
+
*
|
|
729
|
+
* This function returns the total number of `Cause` nodes in the semiring
|
|
730
|
+
* structure, reflecting how many individual error elements are recorded.
|
|
515
731
|
*
|
|
516
732
|
* @since 2.0.0
|
|
517
|
-
* @category
|
|
733
|
+
* @category Getters
|
|
518
734
|
*/
|
|
519
735
|
export const size: <E>(self: Cause<E>) => number = internal.size
|
|
520
736
|
|
|
521
737
|
/**
|
|
522
|
-
*
|
|
738
|
+
* Checks if a `Cause` is entirely empty.
|
|
739
|
+
*
|
|
740
|
+
* **Details**
|
|
741
|
+
*
|
|
742
|
+
* This function returns `true` if the `Cause` contains no errors, defects, or
|
|
743
|
+
* interruptions. It's helpful for verifying if a computation truly had no
|
|
744
|
+
* failures.
|
|
523
745
|
*
|
|
524
746
|
* @since 2.0.0
|
|
525
|
-
* @category
|
|
747
|
+
* @category Getters
|
|
526
748
|
*/
|
|
527
749
|
export const isEmpty: <E>(self: Cause<E>) => boolean = internal.isEmpty
|
|
528
750
|
|
|
529
751
|
/**
|
|
530
|
-
*
|
|
752
|
+
* Checks if a `Cause` contains a failure.
|
|
753
|
+
*
|
|
754
|
+
* **Details**
|
|
755
|
+
*
|
|
756
|
+
* This function returns `true` if the `Cause` includes any `Fail` error. It's
|
|
757
|
+
* commonly used to confirm whether a workflow encountered an anticipated error
|
|
758
|
+
* versus just defects or interruptions.
|
|
531
759
|
*
|
|
532
760
|
* @since 2.0.0
|
|
533
|
-
* @category
|
|
761
|
+
* @category Getters
|
|
534
762
|
*/
|
|
535
763
|
export const isFailure: <E>(self: Cause<E>) => boolean = internal.isFailure
|
|
536
764
|
|
|
537
765
|
/**
|
|
538
|
-
*
|
|
766
|
+
* Checks if a `Cause` contains a defect.
|
|
767
|
+
*
|
|
768
|
+
* **Details**
|
|
769
|
+
*
|
|
770
|
+
* This function returns `true` if the `Cause` includes any unexpected or
|
|
771
|
+
* unhandled errors (`Die`). It's useful for differentiating known failures from
|
|
772
|
+
* unexpected ones.
|
|
539
773
|
*
|
|
540
774
|
* @since 2.0.0
|
|
541
|
-
* @category
|
|
775
|
+
* @category Getters
|
|
542
776
|
*/
|
|
543
777
|
export const isDie: <E>(self: Cause<E>) => boolean = internal.isDie
|
|
544
778
|
|
|
545
779
|
/**
|
|
546
|
-
*
|
|
547
|
-
*
|
|
780
|
+
* Checks if a `Cause` contains an interruption.
|
|
781
|
+
*
|
|
782
|
+
* **Details**
|
|
783
|
+
*
|
|
784
|
+
* This function returns `true` if the `Cause` includes any fiber interruptions.
|
|
548
785
|
*
|
|
549
786
|
* @since 2.0.0
|
|
550
|
-
* @category
|
|
787
|
+
* @category Getters
|
|
551
788
|
*/
|
|
552
789
|
export const isInterrupted: <E>(self: Cause<E>) => boolean = internal.isInterrupted
|
|
553
790
|
|
|
554
791
|
/**
|
|
555
|
-
*
|
|
556
|
-
*
|
|
792
|
+
* Checks if a `Cause` contains only interruptions.
|
|
793
|
+
*
|
|
794
|
+
* **Details**
|
|
795
|
+
*
|
|
796
|
+
* This function returns `true` if the `Cause` has been interrupted but does not
|
|
797
|
+
* contain any other failures, such as `Fail` or `Die`. It's helpful for
|
|
798
|
+
* verifying purely "cancellation" scenarios.
|
|
557
799
|
*
|
|
558
800
|
* @since 2.0.0
|
|
559
|
-
* @category
|
|
801
|
+
* @category Getters
|
|
560
802
|
*/
|
|
561
803
|
export const isInterruptedOnly: <E>(self: Cause<E>) => boolean = internal.isInterruptedOnly
|
|
562
804
|
|
|
563
805
|
/**
|
|
564
|
-
*
|
|
565
|
-
*
|
|
806
|
+
* Extracts all recoverable errors of type `E` from a `Cause`.
|
|
807
|
+
*
|
|
808
|
+
* **Details**
|
|
809
|
+
*
|
|
810
|
+
* This function returns a chunk of errors, providing a list of all `Fail`
|
|
811
|
+
* values found in the cause. It's useful for collecting all known failures for
|
|
812
|
+
* logging or combined error handling.
|
|
566
813
|
*
|
|
567
814
|
* @since 2.0.0
|
|
568
|
-
* @category
|
|
815
|
+
* @category Getters
|
|
569
816
|
*/
|
|
570
817
|
export const failures: <E>(self: Cause<E>) => Chunk.Chunk<E> = internal.failures
|
|
571
818
|
|
|
572
819
|
/**
|
|
573
|
-
*
|
|
820
|
+
* Extracts all unrecoverable defects from a `Cause`.
|
|
821
|
+
*
|
|
822
|
+
* **Details**
|
|
823
|
+
*
|
|
824
|
+
* This function returns a chunk of values representing unexpected errors
|
|
825
|
+
* (`Die`). It's handy for capturing or logging unanticipated failures that
|
|
826
|
+
* might need special handling, such as bug reports.
|
|
574
827
|
*
|
|
575
828
|
* @since 2.0.0
|
|
576
|
-
* @category
|
|
829
|
+
* @category Getters
|
|
577
830
|
*/
|
|
578
831
|
export const defects: <E>(self: Cause<E>) => Chunk.Chunk<unknown> = internal.defects
|
|
579
832
|
|
|
580
833
|
/**
|
|
581
|
-
*
|
|
582
|
-
*
|
|
834
|
+
* Collects all `FiberId`s responsible for interrupting a fiber.
|
|
835
|
+
*
|
|
836
|
+
* **Details**
|
|
837
|
+
*
|
|
838
|
+
* This function returns a set of IDs indicating which fibers caused
|
|
839
|
+
* interruptions within this `Cause`. It's useful for debugging concurrency
|
|
840
|
+
* issues or tracing cancellations.
|
|
583
841
|
*
|
|
584
842
|
* @since 2.0.0
|
|
585
|
-
* @category
|
|
843
|
+
* @category Getters
|
|
586
844
|
*/
|
|
587
845
|
export const interruptors: <E>(self: Cause<E>) => HashSet.HashSet<FiberId.FiberId> = internal.interruptors
|
|
588
846
|
|
|
589
847
|
/**
|
|
590
|
-
*
|
|
591
|
-
*
|
|
848
|
+
* Retrieves the first `Fail` error in a `Cause`, if present.
|
|
849
|
+
*
|
|
850
|
+
* **Details**
|
|
851
|
+
*
|
|
852
|
+
* This function returns an `Option` containing the first recoverable error
|
|
853
|
+
* (`E`) from the cause. It's often used to quickly check if there's a primary
|
|
854
|
+
* error to handle or display.
|
|
592
855
|
*
|
|
593
856
|
* @since 2.0.0
|
|
594
|
-
* @category
|
|
857
|
+
* @category Getters
|
|
595
858
|
*/
|
|
596
859
|
export const failureOption: <E>(self: Cause<E>) => Option.Option<E> = internal.failureOption
|
|
597
860
|
|
|
598
861
|
/**
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
862
|
+
* Splits a `Cause` into either its first `Fail` error or the rest of the cause
|
|
863
|
+
* (which might only contain `Die` or `Interrupt`).
|
|
864
|
+
*
|
|
865
|
+
* **Details**
|
|
866
|
+
*
|
|
867
|
+
* This function either returns the checked error (`E`) or the remaining
|
|
868
|
+
* `Cause<never>` with defects/interruptions. It helps you decide if there's a
|
|
869
|
+
* recoverable path or if only unhandled issues remain.
|
|
602
870
|
*
|
|
603
871
|
* @since 2.0.0
|
|
604
|
-
* @category
|
|
872
|
+
* @category Getters
|
|
605
873
|
*/
|
|
606
874
|
export const failureOrCause: <E>(self: Cause<E>) => Either.Either<Cause<never>, E> = internal.failureOrCause
|
|
607
875
|
|
|
608
876
|
/**
|
|
609
|
-
*
|
|
610
|
-
*
|
|
877
|
+
* Strips out failures with an error of `None` from a `Cause<Option<E>>`.
|
|
878
|
+
*
|
|
879
|
+
* **Details**
|
|
880
|
+
*
|
|
881
|
+
* This function turns a `Cause<Option<E>>` into an `Option<Cause<E>>`. If the
|
|
882
|
+
* cause only contains failures of `None`, it becomes `None`; otherwise, it
|
|
883
|
+
* returns a `Cause` of the remaining errors. It's helpful when working with
|
|
884
|
+
* optional errors and filtering out certain error paths.
|
|
611
885
|
*
|
|
612
886
|
* @since 2.0.0
|
|
613
|
-
* @category
|
|
887
|
+
* @category Getters
|
|
614
888
|
*/
|
|
615
889
|
export const flipCauseOption: <E>(self: Cause<Option.Option<E>>) => Option.Option<Cause<E>> = internal.flipCauseOption
|
|
616
890
|
|
|
617
891
|
/**
|
|
618
|
-
*
|
|
619
|
-
*
|
|
892
|
+
* Retrieves the first `Die` defect in a `Cause`, if present.
|
|
893
|
+
*
|
|
894
|
+
* **Details**
|
|
895
|
+
*
|
|
896
|
+
* This function returns an `Option` containing the first unexpected failure
|
|
897
|
+
* (`Die`) discovered. It's helpful for diagnosing the primary defect in a chain
|
|
898
|
+
* of errors.
|
|
620
899
|
*
|
|
621
900
|
* @since 2.0.0
|
|
622
|
-
* @category
|
|
901
|
+
* @category Getters
|
|
623
902
|
*/
|
|
624
903
|
export const dieOption: <E>(self: Cause<E>) => Option.Option<unknown> = internal.dieOption
|
|
625
904
|
|
|
626
905
|
/**
|
|
627
|
-
*
|
|
628
|
-
*
|
|
906
|
+
* Retrieves the first `Interrupt` in a `Cause`, if present.
|
|
907
|
+
*
|
|
908
|
+
* **Details**
|
|
909
|
+
*
|
|
910
|
+
* This function returns an `Option` with the first fiber interruption
|
|
911
|
+
* discovered. This is particularly useful for concurrency analysis or debugging
|
|
912
|
+
* cancellations.
|
|
629
913
|
*
|
|
630
914
|
* @since 2.0.0
|
|
631
|
-
* @category
|
|
915
|
+
* @category Getters
|
|
632
916
|
*/
|
|
633
917
|
export const interruptOption: <E>(self: Cause<E>) => Option.Option<FiberId.FiberId> = internal.interruptOption
|
|
634
918
|
|
|
635
919
|
/**
|
|
636
|
-
*
|
|
637
|
-
*
|
|
920
|
+
* Removes all `Fail` and `Interrupt` nodes, keeping only defects (`Die`) in a
|
|
921
|
+
* `Cause`.
|
|
922
|
+
*
|
|
923
|
+
* **Details**
|
|
924
|
+
*
|
|
925
|
+
* This function strips a cause of recoverable errors and interruptions, leaving
|
|
926
|
+
* only unexpected failures. If no defects remain, it returns `None`. It's
|
|
927
|
+
* valuable for focusing only on unanticipated problems when both known errors
|
|
928
|
+
* and defects could occur.
|
|
638
929
|
*
|
|
639
930
|
* @since 2.0.0
|
|
640
|
-
* @category
|
|
931
|
+
* @category Getters
|
|
641
932
|
*/
|
|
642
933
|
export const keepDefects: <E>(self: Cause<E>) => Option.Option<Cause<never>> = internal.keepDefects
|
|
643
934
|
|
|
935
|
+
// TODO(4.0): remove? what's the point of this API?
|
|
644
936
|
/**
|
|
645
|
-
* Linearizes
|
|
646
|
-
*
|
|
937
|
+
* Linearizes a `Cause` into a set of parallel causes, each containing a
|
|
938
|
+
* sequential chain of failures.
|
|
939
|
+
*
|
|
940
|
+
* **Details**
|
|
941
|
+
*
|
|
942
|
+
* This function reorganizes the cause structure so that you can analyze each
|
|
943
|
+
* parallel branch separately, even if they have multiple sequential errors.
|
|
647
944
|
*
|
|
648
945
|
* @since 2.0.0
|
|
649
|
-
* @category
|
|
946
|
+
* @category Getters
|
|
650
947
|
*/
|
|
651
948
|
export const linearize: <E>(self: Cause<E>) => HashSet.HashSet<Cause<E>> = internal.linearize
|
|
652
949
|
|
|
653
950
|
/**
|
|
654
|
-
*
|
|
655
|
-
*
|
|
951
|
+
* Removes `Fail` and `Interrupt` nodes from a `Cause`, keeping only defects
|
|
952
|
+
* (`Die`).
|
|
953
|
+
*
|
|
954
|
+
* **Details**
|
|
955
|
+
*
|
|
956
|
+
* This function is similar to `keepDefects` but returns a `Cause<never>`
|
|
957
|
+
* directly, which can still store `Die` or finalizer-related defects. It's
|
|
958
|
+
* helpful for analyzing only the irrecoverable portion of the error.
|
|
656
959
|
*
|
|
657
960
|
* @since 2.0.0
|
|
658
|
-
* @category
|
|
961
|
+
* @category Getters
|
|
659
962
|
*/
|
|
660
963
|
export const stripFailures: <E>(self: Cause<E>) => Cause<never> = internal.stripFailures
|
|
661
964
|
|
|
662
965
|
/**
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
966
|
+
* Removes matching defects from a `Cause` using a partial function, returning
|
|
967
|
+
* the remainder.
|
|
968
|
+
*
|
|
969
|
+
* **Details**
|
|
970
|
+
*
|
|
971
|
+
* This function applies a user-defined extraction function to each defect
|
|
972
|
+
* (`Die`). If the function matches the defect, that defect is removed. If all
|
|
973
|
+
* defects match, the result is `None`. Otherwise, you get a `Cause` with the
|
|
974
|
+
* unmatched defects.
|
|
666
975
|
*
|
|
667
976
|
* @since 2.0.0
|
|
668
|
-
* @category
|
|
977
|
+
* @category Getters
|
|
669
978
|
*/
|
|
670
979
|
export const stripSomeDefects: {
|
|
671
980
|
/**
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
981
|
+
* Removes matching defects from a `Cause` using a partial function, returning
|
|
982
|
+
* the remainder.
|
|
983
|
+
*
|
|
984
|
+
* **Details**
|
|
985
|
+
*
|
|
986
|
+
* This function applies a user-defined extraction function to each defect
|
|
987
|
+
* (`Die`). If the function matches the defect, that defect is removed. If all
|
|
988
|
+
* defects match, the result is `None`. Otherwise, you get a `Cause` with the
|
|
989
|
+
* unmatched defects.
|
|
675
990
|
*
|
|
676
991
|
* @since 2.0.0
|
|
677
|
-
* @category
|
|
992
|
+
* @category Getters
|
|
678
993
|
*/
|
|
679
994
|
(pf: (defect: unknown) => Option.Option<unknown>): <E>(self: Cause<E>) => Option.Option<Cause<E>>
|
|
680
995
|
/**
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
996
|
+
* Removes matching defects from a `Cause` using a partial function, returning
|
|
997
|
+
* the remainder.
|
|
998
|
+
*
|
|
999
|
+
* **Details**
|
|
1000
|
+
*
|
|
1001
|
+
* This function applies a user-defined extraction function to each defect
|
|
1002
|
+
* (`Die`). If the function matches the defect, that defect is removed. If all
|
|
1003
|
+
* defects match, the result is `None`. Otherwise, you get a `Cause` with the
|
|
1004
|
+
* unmatched defects.
|
|
684
1005
|
*
|
|
685
1006
|
* @since 2.0.0
|
|
686
|
-
* @category
|
|
1007
|
+
* @category Getters
|
|
687
1008
|
*/
|
|
688
1009
|
<E>(self: Cause<E>, pf: (defect: unknown) => Option.Option<unknown>): Option.Option<Cause<E>>
|
|
689
1010
|
} = internal.stripSomeDefects
|
|
690
1011
|
|
|
691
1012
|
/**
|
|
1013
|
+
* Replaces any errors in a `Cause` with a provided constant error.
|
|
1014
|
+
*
|
|
1015
|
+
* **Details**
|
|
1016
|
+
*
|
|
1017
|
+
* This function transforms all `Fail` errors into the specified error value,
|
|
1018
|
+
* preserving the structure of the `Cause`. It's useful when you no longer need
|
|
1019
|
+
* the original error details but still want to keep the cause shape.
|
|
1020
|
+
*
|
|
1021
|
+
* @see {@link map} Apply a custom transformation to `Fail` errors
|
|
1022
|
+
*
|
|
692
1023
|
* @since 2.0.0
|
|
693
|
-
* @category
|
|
1024
|
+
* @category Mapping
|
|
694
1025
|
*/
|
|
695
1026
|
export const as: {
|
|
696
1027
|
/**
|
|
1028
|
+
* Replaces any errors in a `Cause` with a provided constant error.
|
|
1029
|
+
*
|
|
1030
|
+
* **Details**
|
|
1031
|
+
*
|
|
1032
|
+
* This function transforms all `Fail` errors into the specified error value,
|
|
1033
|
+
* preserving the structure of the `Cause`. It's useful when you no longer need
|
|
1034
|
+
* the original error details but still want to keep the cause shape.
|
|
1035
|
+
*
|
|
1036
|
+
* @see {@link map} Apply a custom transformation to `Fail` errors
|
|
1037
|
+
*
|
|
697
1038
|
* @since 2.0.0
|
|
698
|
-
* @category
|
|
1039
|
+
* @category Mapping
|
|
699
1040
|
*/
|
|
700
1041
|
<E2>(error: E2): <E>(self: Cause<E>) => Cause<E2>
|
|
701
1042
|
/**
|
|
1043
|
+
* Replaces any errors in a `Cause` with a provided constant error.
|
|
1044
|
+
*
|
|
1045
|
+
* **Details**
|
|
1046
|
+
*
|
|
1047
|
+
* This function transforms all `Fail` errors into the specified error value,
|
|
1048
|
+
* preserving the structure of the `Cause`. It's useful when you no longer need
|
|
1049
|
+
* the original error details but still want to keep the cause shape.
|
|
1050
|
+
*
|
|
1051
|
+
* @see {@link map} Apply a custom transformation to `Fail` errors
|
|
1052
|
+
*
|
|
702
1053
|
* @since 2.0.0
|
|
703
|
-
* @category
|
|
1054
|
+
* @category Mapping
|
|
704
1055
|
*/
|
|
705
1056
|
<E, E2>(self: Cause<E>, error: E2): Cause<E2>
|
|
706
1057
|
} = internal.as
|
|
707
1058
|
|
|
708
1059
|
/**
|
|
1060
|
+
* Transforms the errors in a `Cause` using a user-provided function.
|
|
1061
|
+
*
|
|
1062
|
+
* **Details**
|
|
1063
|
+
*
|
|
1064
|
+
* This function applies `f` to each `Fail` error while leaving defects (`Die`)
|
|
1065
|
+
* and interruptions untouched. It's useful for changing or simplifying error
|
|
1066
|
+
* types in your effectful workflows.
|
|
1067
|
+
*
|
|
1068
|
+
* @see {@link as} Replace errors with a single constant
|
|
1069
|
+
*
|
|
709
1070
|
* @since 2.0.0
|
|
710
|
-
* @category
|
|
1071
|
+
* @category Mapping
|
|
711
1072
|
*/
|
|
712
1073
|
export const map: {
|
|
713
1074
|
/**
|
|
1075
|
+
* Transforms the errors in a `Cause` using a user-provided function.
|
|
1076
|
+
*
|
|
1077
|
+
* **Details**
|
|
1078
|
+
*
|
|
1079
|
+
* This function applies `f` to each `Fail` error while leaving defects (`Die`)
|
|
1080
|
+
* and interruptions untouched. It's useful for changing or simplifying error
|
|
1081
|
+
* types in your effectful workflows.
|
|
1082
|
+
*
|
|
1083
|
+
* @see {@link as} Replace errors with a single constant
|
|
1084
|
+
*
|
|
714
1085
|
* @since 2.0.0
|
|
715
|
-
* @category
|
|
1086
|
+
* @category Mapping
|
|
716
1087
|
*/
|
|
717
1088
|
<E, E2>(f: (e: E) => E2): (self: Cause<E>) => Cause<E2>
|
|
718
1089
|
/**
|
|
1090
|
+
* Transforms the errors in a `Cause` using a user-provided function.
|
|
1091
|
+
*
|
|
1092
|
+
* **Details**
|
|
1093
|
+
*
|
|
1094
|
+
* This function applies `f` to each `Fail` error while leaving defects (`Die`)
|
|
1095
|
+
* and interruptions untouched. It's useful for changing or simplifying error
|
|
1096
|
+
* types in your effectful workflows.
|
|
1097
|
+
*
|
|
1098
|
+
* @see {@link as} Replace errors with a single constant
|
|
1099
|
+
*
|
|
719
1100
|
* @since 2.0.0
|
|
720
|
-
* @category
|
|
1101
|
+
* @category Mapping
|
|
721
1102
|
*/
|
|
722
1103
|
<E, E2>(self: Cause<E>, f: (e: E) => E2): Cause<E2>
|
|
723
1104
|
} = internal.map
|
|
724
1105
|
|
|
725
1106
|
/**
|
|
1107
|
+
* Transforms errors in a `Cause` into new causes.
|
|
1108
|
+
*
|
|
1109
|
+
* **Details**
|
|
1110
|
+
*
|
|
1111
|
+
* This function applies a function `f` to each `Fail` error, converting it into
|
|
1112
|
+
* a new `Cause`. This is especially powerful for merging or restructuring error
|
|
1113
|
+
* types while preserving or combining cause information.
|
|
1114
|
+
*
|
|
1115
|
+
* @see {@link map} Apply a simpler transformation to errors
|
|
1116
|
+
*
|
|
726
1117
|
* @since 2.0.0
|
|
727
|
-
* @category
|
|
1118
|
+
* @category Sequencing
|
|
728
1119
|
*/
|
|
729
1120
|
export const flatMap: {
|
|
730
1121
|
/**
|
|
1122
|
+
* Transforms errors in a `Cause` into new causes.
|
|
1123
|
+
*
|
|
1124
|
+
* **Details**
|
|
1125
|
+
*
|
|
1126
|
+
* This function applies a function `f` to each `Fail` error, converting it into
|
|
1127
|
+
* a new `Cause`. This is especially powerful for merging or restructuring error
|
|
1128
|
+
* types while preserving or combining cause information.
|
|
1129
|
+
*
|
|
1130
|
+
* @see {@link map} Apply a simpler transformation to errors
|
|
1131
|
+
*
|
|
731
1132
|
* @since 2.0.0
|
|
732
|
-
* @category
|
|
1133
|
+
* @category Sequencing
|
|
733
1134
|
*/
|
|
734
1135
|
<E, E2>(f: (e: E) => Cause<E2>): (self: Cause<E>) => Cause<E2>
|
|
735
1136
|
/**
|
|
1137
|
+
* Transforms errors in a `Cause` into new causes.
|
|
1138
|
+
*
|
|
1139
|
+
* **Details**
|
|
1140
|
+
*
|
|
1141
|
+
* This function applies a function `f` to each `Fail` error, converting it into
|
|
1142
|
+
* a new `Cause`. This is especially powerful for merging or restructuring error
|
|
1143
|
+
* types while preserving or combining cause information.
|
|
1144
|
+
*
|
|
1145
|
+
* @see {@link map} Apply a simpler transformation to errors
|
|
1146
|
+
*
|
|
736
1147
|
* @since 2.0.0
|
|
737
|
-
* @category
|
|
1148
|
+
* @category Sequencing
|
|
738
1149
|
*/
|
|
739
1150
|
<E, E2>(self: Cause<E>, f: (e: E) => Cause<E2>): Cause<E2>
|
|
740
1151
|
} = internal.flatMap
|
|
741
1152
|
|
|
742
1153
|
/**
|
|
743
|
-
*
|
|
1154
|
+
* Sequences two `Cause`s. The second `Cause` can be dependent on the result of
|
|
1155
|
+
* the first `Cause`.
|
|
744
1156
|
*
|
|
745
1157
|
* @since 2.0.0
|
|
746
|
-
* @category
|
|
1158
|
+
* @category Sequencing
|
|
747
1159
|
*/
|
|
748
1160
|
export const andThen: {
|
|
749
1161
|
/**
|
|
750
|
-
*
|
|
1162
|
+
* Sequences two `Cause`s. The second `Cause` can be dependent on the result of
|
|
1163
|
+
* the first `Cause`.
|
|
751
1164
|
*
|
|
752
1165
|
* @since 2.0.0
|
|
753
|
-
* @category
|
|
1166
|
+
* @category Sequencing
|
|
754
1167
|
*/
|
|
755
1168
|
<E, E2>(f: (e: E) => Cause<E2>): (self: Cause<E>) => Cause<E2>
|
|
756
1169
|
/**
|
|
757
|
-
*
|
|
1170
|
+
* Sequences two `Cause`s. The second `Cause` can be dependent on the result of
|
|
1171
|
+
* the first `Cause`.
|
|
758
1172
|
*
|
|
759
1173
|
* @since 2.0.0
|
|
760
|
-
* @category
|
|
1174
|
+
* @category Sequencing
|
|
761
1175
|
*/
|
|
762
1176
|
<E2>(f: Cause<E2>): <E>(self: Cause<E>) => Cause<E2>
|
|
763
1177
|
/**
|
|
764
|
-
*
|
|
1178
|
+
* Sequences two `Cause`s. The second `Cause` can be dependent on the result of
|
|
1179
|
+
* the first `Cause`.
|
|
765
1180
|
*
|
|
766
1181
|
* @since 2.0.0
|
|
767
|
-
* @category
|
|
1182
|
+
* @category Sequencing
|
|
768
1183
|
*/
|
|
769
1184
|
<E, E2>(self: Cause<E>, f: (e: E) => Cause<E2>): Cause<E2>
|
|
770
1185
|
/**
|
|
771
|
-
*
|
|
1186
|
+
* Sequences two `Cause`s. The second `Cause` can be dependent on the result of
|
|
1187
|
+
* the first `Cause`.
|
|
772
1188
|
*
|
|
773
1189
|
* @since 2.0.0
|
|
774
|
-
* @category
|
|
1190
|
+
* @category Sequencing
|
|
775
1191
|
*/
|
|
776
1192
|
<E, E2>(self: Cause<E>, f: Cause<E2>): Cause<E2>
|
|
777
1193
|
} = internal.andThen
|
|
778
1194
|
|
|
779
1195
|
/**
|
|
1196
|
+
* Flattens a nested `Cause` structure.
|
|
1197
|
+
*
|
|
1198
|
+
* **Details**
|
|
1199
|
+
*
|
|
1200
|
+
* This function takes a `Cause<Cause<E>>` and merges the layers into a single
|
|
1201
|
+
* `Cause<E>`. It's useful for eliminating additional nesting created by
|
|
1202
|
+
* repeated transformations or compositions.
|
|
1203
|
+
*
|
|
1204
|
+
* @see {@link flatMap} Compose nested causes
|
|
1205
|
+
*
|
|
780
1206
|
* @since 2.0.0
|
|
781
|
-
* @category
|
|
1207
|
+
* @category Sequencing
|
|
782
1208
|
*/
|
|
783
1209
|
export const flatten: <E>(self: Cause<Cause<E>>) => Cause<E> = internal.flatten
|
|
784
1210
|
|
|
785
1211
|
/**
|
|
786
|
-
*
|
|
787
|
-
*
|
|
1212
|
+
* Checks if the current `Cause` contains or is equal to another `Cause`.
|
|
1213
|
+
*
|
|
1214
|
+
* **Details**
|
|
1215
|
+
*
|
|
1216
|
+
* This function returns `true` if `that` cause is part of or the same as
|
|
1217
|
+
* the current `Cause`. It's useful when you need to check for specific
|
|
1218
|
+
* error patterns or deduplicate repeated failures.
|
|
788
1219
|
*
|
|
789
1220
|
* @since 2.0.0
|
|
790
|
-
* @category
|
|
1221
|
+
* @category Elements
|
|
791
1222
|
*/
|
|
792
1223
|
export const contains: {
|
|
793
1224
|
/**
|
|
794
|
-
*
|
|
795
|
-
*
|
|
1225
|
+
* Checks if the current `Cause` contains or is equal to another `Cause`.
|
|
1226
|
+
*
|
|
1227
|
+
* **Details**
|
|
1228
|
+
*
|
|
1229
|
+
* This function returns `true` if `that` cause is part of or the same as
|
|
1230
|
+
* the current `Cause`. It's useful when you need to check for specific
|
|
1231
|
+
* error patterns or deduplicate repeated failures.
|
|
796
1232
|
*
|
|
797
1233
|
* @since 2.0.0
|
|
798
|
-
* @category
|
|
1234
|
+
* @category Elements
|
|
799
1235
|
*/
|
|
800
1236
|
<E2>(that: Cause<E2>): <E>(self: Cause<E>) => boolean
|
|
801
1237
|
/**
|
|
802
|
-
*
|
|
803
|
-
*
|
|
1238
|
+
* Checks if the current `Cause` contains or is equal to another `Cause`.
|
|
1239
|
+
*
|
|
1240
|
+
* **Details**
|
|
1241
|
+
*
|
|
1242
|
+
* This function returns `true` if `that` cause is part of or the same as
|
|
1243
|
+
* the current `Cause`. It's useful when you need to check for specific
|
|
1244
|
+
* error patterns or deduplicate repeated failures.
|
|
804
1245
|
*
|
|
805
1246
|
* @since 2.0.0
|
|
806
|
-
* @category
|
|
1247
|
+
* @category Elements
|
|
807
1248
|
*/
|
|
808
1249
|
<E, E2>(self: Cause<E>, that: Cause<E2>): boolean
|
|
809
1250
|
} = internal.contains
|
|
810
1251
|
|
|
811
1252
|
/**
|
|
812
|
-
*
|
|
813
|
-
*
|
|
1253
|
+
* Extracts the most "important" defect from a `Cause`.
|
|
1254
|
+
*
|
|
1255
|
+
* **Details**
|
|
1256
|
+
*
|
|
1257
|
+
* This function reduces a `Cause` to a single, prioritized defect. It evaluates
|
|
1258
|
+
* the `Cause` in the following order of priority:
|
|
1259
|
+
*
|
|
1260
|
+
* 1. If the `Cause` contains a failure (e.g., from `Effect.fail`), it returns
|
|
1261
|
+
* the raw error value.
|
|
1262
|
+
* 2. If there is no failure, it looks for the first defect (e.g., from
|
|
1263
|
+
* `Effect.die`).
|
|
1264
|
+
* 3. If neither of the above is present, and the `Cause` stems from an
|
|
1265
|
+
* interruption, it creates and returns an `InterruptedException`.
|
|
1266
|
+
*
|
|
1267
|
+
* This function ensures you can always extract a meaningful representation of
|
|
1268
|
+
* the primary issue from a potentially complex `Cause` structure.
|
|
1269
|
+
*
|
|
1270
|
+
* **When to Use**
|
|
1271
|
+
*
|
|
1272
|
+
* Use this function when you need to extract the most relevant error or defect
|
|
1273
|
+
* from a `Cause`, especially in scenarios where multiple errors or defects may
|
|
1274
|
+
* be present. It's particularly useful for simplifying error reporting or
|
|
1275
|
+
* logging.
|
|
1276
|
+
*
|
|
1277
|
+
* @see {@link squashWith} Allows transforming failures into defects when squashing.
|
|
814
1278
|
*
|
|
815
1279
|
* @since 2.0.0
|
|
816
|
-
* @category
|
|
1280
|
+
* @category Destructors
|
|
817
1281
|
*/
|
|
818
1282
|
export const squash: <E>(self: Cause<E>) => unknown = core.causeSquash
|
|
819
1283
|
|
|
820
1284
|
/**
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
*
|
|
1285
|
+
* Extracts the most "important" defect from a `Cause`, transforming failures
|
|
1286
|
+
* into defects using a provided function.
|
|
1287
|
+
*
|
|
1288
|
+
* **Details**
|
|
1289
|
+
*
|
|
1290
|
+
* This function reduces a `Cause` to a single, prioritized defect, while
|
|
1291
|
+
* allowing you to transform recoverable failures into defects through a custom
|
|
1292
|
+
* function. It processes the `Cause` in the following order:
|
|
1293
|
+
*
|
|
1294
|
+
* 1. If the `Cause` contains a failure (e.g., from `Effect.fail`), it applies
|
|
1295
|
+
* the provided function `f` to the error to transform it into a defect.
|
|
1296
|
+
* 2. If there is no failure, it looks for the first defect (e.g., from
|
|
1297
|
+
* `Effect.die`) and returns it.
|
|
1298
|
+
* 3. If neither is present and the `Cause` stems from an interruption, it
|
|
1299
|
+
* returns an `InterruptedException`.
|
|
1300
|
+
*
|
|
1301
|
+
* This function is particularly useful when you need custom handling or
|
|
1302
|
+
* transformation of errors while processing a `Cause`.
|
|
1303
|
+
*
|
|
1304
|
+
* @see {@link squash} Extracts the most "important" defect without transforming failures.
|
|
824
1305
|
*
|
|
825
1306
|
* @since 2.0.0
|
|
826
|
-
* @category
|
|
1307
|
+
* @category Destructors
|
|
827
1308
|
*/
|
|
828
1309
|
export const squashWith: {
|
|
829
1310
|
/**
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
1311
|
+
* Extracts the most "important" defect from a `Cause`, transforming failures
|
|
1312
|
+
* into defects using a provided function.
|
|
1313
|
+
*
|
|
1314
|
+
* **Details**
|
|
1315
|
+
*
|
|
1316
|
+
* This function reduces a `Cause` to a single, prioritized defect, while
|
|
1317
|
+
* allowing you to transform recoverable failures into defects through a custom
|
|
1318
|
+
* function. It processes the `Cause` in the following order:
|
|
1319
|
+
*
|
|
1320
|
+
* 1. If the `Cause` contains a failure (e.g., from `Effect.fail`), it applies
|
|
1321
|
+
* the provided function `f` to the error to transform it into a defect.
|
|
1322
|
+
* 2. If there is no failure, it looks for the first defect (e.g., from
|
|
1323
|
+
* `Effect.die`) and returns it.
|
|
1324
|
+
* 3. If neither is present and the `Cause` stems from an interruption, it
|
|
1325
|
+
* returns an `InterruptedException`.
|
|
1326
|
+
*
|
|
1327
|
+
* This function is particularly useful when you need custom handling or
|
|
1328
|
+
* transformation of errors while processing a `Cause`.
|
|
1329
|
+
*
|
|
1330
|
+
* @see {@link squash} Extracts the most "important" defect without transforming failures.
|
|
833
1331
|
*
|
|
834
1332
|
* @since 2.0.0
|
|
835
|
-
* @category
|
|
1333
|
+
* @category Destructors
|
|
836
1334
|
*/
|
|
837
1335
|
<E>(f: (error: E) => unknown): (self: Cause<E>) => unknown
|
|
838
1336
|
/**
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
*
|
|
1337
|
+
* Extracts the most "important" defect from a `Cause`, transforming failures
|
|
1338
|
+
* into defects using a provided function.
|
|
1339
|
+
*
|
|
1340
|
+
* **Details**
|
|
1341
|
+
*
|
|
1342
|
+
* This function reduces a `Cause` to a single, prioritized defect, while
|
|
1343
|
+
* allowing you to transform recoverable failures into defects through a custom
|
|
1344
|
+
* function. It processes the `Cause` in the following order:
|
|
1345
|
+
*
|
|
1346
|
+
* 1. If the `Cause` contains a failure (e.g., from `Effect.fail`), it applies
|
|
1347
|
+
* the provided function `f` to the error to transform it into a defect.
|
|
1348
|
+
* 2. If there is no failure, it looks for the first defect (e.g., from
|
|
1349
|
+
* `Effect.die`) and returns it.
|
|
1350
|
+
* 3. If neither is present and the `Cause` stems from an interruption, it
|
|
1351
|
+
* returns an `InterruptedException`.
|
|
1352
|
+
*
|
|
1353
|
+
* This function is particularly useful when you need custom handling or
|
|
1354
|
+
* transformation of errors while processing a `Cause`.
|
|
1355
|
+
*
|
|
1356
|
+
* @see {@link squash} Extracts the most "important" defect without transforming failures.
|
|
842
1357
|
*
|
|
843
1358
|
* @since 2.0.0
|
|
844
|
-
* @category
|
|
1359
|
+
* @category Destructors
|
|
845
1360
|
*/
|
|
846
1361
|
<E>(self: Cause<E>, f: (error: E) => unknown): unknown
|
|
847
1362
|
} = core.causeSquashWith
|
|
848
1363
|
|
|
849
1364
|
/**
|
|
850
|
-
*
|
|
851
|
-
*
|
|
1365
|
+
* Searches a `Cause` using a partial function to extract information.
|
|
1366
|
+
*
|
|
1367
|
+
* **Details**
|
|
1368
|
+
*
|
|
1369
|
+
* This function allows you to search through a `Cause` using a custom partial
|
|
1370
|
+
* function. The partial function is applied to the `Cause`, and if it matches,
|
|
1371
|
+
* the result is returned wrapped in a `Some`. If no match is found, the result
|
|
1372
|
+
* is `None`.
|
|
1373
|
+
*
|
|
1374
|
+
* This is particularly useful when you are only interested in specific types of
|
|
1375
|
+
* errors, defects, or interruption causes within a potentially complex `Cause`
|
|
1376
|
+
* structure. By leveraging a partial function, you can focus on extracting only
|
|
1377
|
+
* the relevant information you care about.
|
|
1378
|
+
*
|
|
1379
|
+
* The partial function should return an `Option` indicating whether it matched
|
|
1380
|
+
* and the value it extracted.
|
|
852
1381
|
*
|
|
853
1382
|
* @since 2.0.0
|
|
854
|
-
* @category
|
|
1383
|
+
* @category Elements
|
|
855
1384
|
*/
|
|
856
1385
|
export const find: {
|
|
857
1386
|
/**
|
|
858
|
-
*
|
|
859
|
-
*
|
|
1387
|
+
* Searches a `Cause` using a partial function to extract information.
|
|
1388
|
+
*
|
|
1389
|
+
* **Details**
|
|
1390
|
+
*
|
|
1391
|
+
* This function allows you to search through a `Cause` using a custom partial
|
|
1392
|
+
* function. The partial function is applied to the `Cause`, and if it matches,
|
|
1393
|
+
* the result is returned wrapped in a `Some`. If no match is found, the result
|
|
1394
|
+
* is `None`.
|
|
1395
|
+
*
|
|
1396
|
+
* This is particularly useful when you are only interested in specific types of
|
|
1397
|
+
* errors, defects, or interruption causes within a potentially complex `Cause`
|
|
1398
|
+
* structure. By leveraging a partial function, you can focus on extracting only
|
|
1399
|
+
* the relevant information you care about.
|
|
1400
|
+
*
|
|
1401
|
+
* The partial function should return an `Option` indicating whether it matched
|
|
1402
|
+
* and the value it extracted.
|
|
860
1403
|
*
|
|
861
1404
|
* @since 2.0.0
|
|
862
|
-
* @category
|
|
1405
|
+
* @category Elements
|
|
863
1406
|
*/
|
|
864
1407
|
<E, Z>(pf: (cause: Cause<E>) => Option.Option<Z>): (self: Cause<E>) => Option.Option<Z>
|
|
865
1408
|
/**
|
|
866
|
-
*
|
|
867
|
-
*
|
|
1409
|
+
* Searches a `Cause` using a partial function to extract information.
|
|
1410
|
+
*
|
|
1411
|
+
* **Details**
|
|
1412
|
+
*
|
|
1413
|
+
* This function allows you to search through a `Cause` using a custom partial
|
|
1414
|
+
* function. The partial function is applied to the `Cause`, and if it matches,
|
|
1415
|
+
* the result is returned wrapped in a `Some`. If no match is found, the result
|
|
1416
|
+
* is `None`.
|
|
1417
|
+
*
|
|
1418
|
+
* This is particularly useful when you are only interested in specific types of
|
|
1419
|
+
* errors, defects, or interruption causes within a potentially complex `Cause`
|
|
1420
|
+
* structure. By leveraging a partial function, you can focus on extracting only
|
|
1421
|
+
* the relevant information you care about.
|
|
1422
|
+
*
|
|
1423
|
+
* The partial function should return an `Option` indicating whether it matched
|
|
1424
|
+
* and the value it extracted.
|
|
868
1425
|
*
|
|
869
1426
|
* @since 2.0.0
|
|
870
|
-
* @category
|
|
1427
|
+
* @category Elements
|
|
871
1428
|
*/
|
|
872
1429
|
<E, Z>(self: Cause<E>, pf: (cause: Cause<E>) => Option.Option<Z>): Option.Option<Z>
|
|
873
1430
|
} = internal.find
|
|
874
1431
|
|
|
875
1432
|
/**
|
|
876
|
-
*
|
|
1433
|
+
* Preserves parts of a `Cause` that match a given predicate.
|
|
1434
|
+
*
|
|
1435
|
+
* **Details**
|
|
1436
|
+
*
|
|
1437
|
+
* This function allows you to retain only the parts of a `Cause` structure that
|
|
1438
|
+
* match a specified predicate or refinement. Any parts of the `Cause` that do
|
|
1439
|
+
* not match the provided condition are excluded from the result.
|
|
1440
|
+
*
|
|
1441
|
+
* You can use this function in two ways:
|
|
1442
|
+
* - With a `Predicate`: A function that evaluates whether a `Cause` should be
|
|
1443
|
+
* retained based on its value.
|
|
1444
|
+
* - With a `Refinement`: A more specific predicate that can refine the type of
|
|
1445
|
+
* the `Cause`.
|
|
1446
|
+
*
|
|
1447
|
+
* This is useful when you need to extract specific types of errors, defects, or
|
|
1448
|
+
* interruptions from a `Cause` while discarding unrelated parts.
|
|
877
1449
|
*
|
|
878
1450
|
* @since 2.0.0
|
|
879
|
-
* @category
|
|
1451
|
+
* @category Filtering
|
|
880
1452
|
*/
|
|
881
1453
|
export const filter: {
|
|
882
1454
|
/**
|
|
883
|
-
*
|
|
1455
|
+
* Preserves parts of a `Cause` that match a given predicate.
|
|
1456
|
+
*
|
|
1457
|
+
* **Details**
|
|
1458
|
+
*
|
|
1459
|
+
* This function allows you to retain only the parts of a `Cause` structure that
|
|
1460
|
+
* match a specified predicate or refinement. Any parts of the `Cause` that do
|
|
1461
|
+
* not match the provided condition are excluded from the result.
|
|
1462
|
+
*
|
|
1463
|
+
* You can use this function in two ways:
|
|
1464
|
+
* - With a `Predicate`: A function that evaluates whether a `Cause` should be
|
|
1465
|
+
* retained based on its value.
|
|
1466
|
+
* - With a `Refinement`: A more specific predicate that can refine the type of
|
|
1467
|
+
* the `Cause`.
|
|
1468
|
+
*
|
|
1469
|
+
* This is useful when you need to extract specific types of errors, defects, or
|
|
1470
|
+
* interruptions from a `Cause` while discarding unrelated parts.
|
|
884
1471
|
*
|
|
885
1472
|
* @since 2.0.0
|
|
886
|
-
* @category
|
|
1473
|
+
* @category Filtering
|
|
887
1474
|
*/
|
|
888
1475
|
<E, EB extends E>(refinement: Refinement<Cause<NoInfer<E>>, Cause<EB>>): (self: Cause<E>) => Cause<EB>
|
|
889
1476
|
/**
|
|
890
|
-
*
|
|
1477
|
+
* Preserves parts of a `Cause` that match a given predicate.
|
|
1478
|
+
*
|
|
1479
|
+
* **Details**
|
|
1480
|
+
*
|
|
1481
|
+
* This function allows you to retain only the parts of a `Cause` structure that
|
|
1482
|
+
* match a specified predicate or refinement. Any parts of the `Cause` that do
|
|
1483
|
+
* not match the provided condition are excluded from the result.
|
|
1484
|
+
*
|
|
1485
|
+
* You can use this function in two ways:
|
|
1486
|
+
* - With a `Predicate`: A function that evaluates whether a `Cause` should be
|
|
1487
|
+
* retained based on its value.
|
|
1488
|
+
* - With a `Refinement`: A more specific predicate that can refine the type of
|
|
1489
|
+
* the `Cause`.
|
|
1490
|
+
*
|
|
1491
|
+
* This is useful when you need to extract specific types of errors, defects, or
|
|
1492
|
+
* interruptions from a `Cause` while discarding unrelated parts.
|
|
891
1493
|
*
|
|
892
1494
|
* @since 2.0.0
|
|
893
|
-
* @category
|
|
1495
|
+
* @category Filtering
|
|
894
1496
|
*/
|
|
895
1497
|
<E>(predicate: Predicate<Cause<NoInfer<E>>>): (self: Cause<E>) => Cause<E>
|
|
896
1498
|
/**
|
|
897
|
-
*
|
|
1499
|
+
* Preserves parts of a `Cause` that match a given predicate.
|
|
1500
|
+
*
|
|
1501
|
+
* **Details**
|
|
1502
|
+
*
|
|
1503
|
+
* This function allows you to retain only the parts of a `Cause` structure that
|
|
1504
|
+
* match a specified predicate or refinement. Any parts of the `Cause` that do
|
|
1505
|
+
* not match the provided condition are excluded from the result.
|
|
1506
|
+
*
|
|
1507
|
+
* You can use this function in two ways:
|
|
1508
|
+
* - With a `Predicate`: A function that evaluates whether a `Cause` should be
|
|
1509
|
+
* retained based on its value.
|
|
1510
|
+
* - With a `Refinement`: A more specific predicate that can refine the type of
|
|
1511
|
+
* the `Cause`.
|
|
1512
|
+
*
|
|
1513
|
+
* This is useful when you need to extract specific types of errors, defects, or
|
|
1514
|
+
* interruptions from a `Cause` while discarding unrelated parts.
|
|
898
1515
|
*
|
|
899
1516
|
* @since 2.0.0
|
|
900
|
-
* @category
|
|
1517
|
+
* @category Filtering
|
|
901
1518
|
*/
|
|
902
1519
|
<E, EB extends E>(self: Cause<E>, refinement: Refinement<Cause<E>, Cause<EB>>): Cause<EB>
|
|
903
1520
|
/**
|
|
904
|
-
*
|
|
1521
|
+
* Preserves parts of a `Cause` that match a given predicate.
|
|
1522
|
+
*
|
|
1523
|
+
* **Details**
|
|
1524
|
+
*
|
|
1525
|
+
* This function allows you to retain only the parts of a `Cause` structure that
|
|
1526
|
+
* match a specified predicate or refinement. Any parts of the `Cause` that do
|
|
1527
|
+
* not match the provided condition are excluded from the result.
|
|
1528
|
+
*
|
|
1529
|
+
* You can use this function in two ways:
|
|
1530
|
+
* - With a `Predicate`: A function that evaluates whether a `Cause` should be
|
|
1531
|
+
* retained based on its value.
|
|
1532
|
+
* - With a `Refinement`: A more specific predicate that can refine the type of
|
|
1533
|
+
* the `Cause`.
|
|
1534
|
+
*
|
|
1535
|
+
* This is useful when you need to extract specific types of errors, defects, or
|
|
1536
|
+
* interruptions from a `Cause` while discarding unrelated parts.
|
|
905
1537
|
*
|
|
906
1538
|
* @since 2.0.0
|
|
907
|
-
* @category
|
|
1539
|
+
* @category Filtering
|
|
908
1540
|
*/
|
|
909
1541
|
<E>(self: Cause<E>, predicate: Predicate<Cause<E>>): Cause<E>
|
|
910
1542
|
} = internal.filter
|
|
911
1543
|
|
|
912
1544
|
/**
|
|
913
|
-
*
|
|
1545
|
+
* Transforms a `Cause` into a single value using custom handlers for each
|
|
1546
|
+
* possible case.
|
|
1547
|
+
*
|
|
1548
|
+
* **Details**
|
|
1549
|
+
*
|
|
1550
|
+
* This function processes a `Cause` by applying a set of custom handlers to
|
|
1551
|
+
* each possible type of cause: `Empty`, `Fail`, `Die`, `Interrupt`,
|
|
1552
|
+
* `Sequential`, and `Parallel`. The result of this function is a single value
|
|
1553
|
+
* of type `Z`. This function allows you to define exactly how to handle each
|
|
1554
|
+
* part of a `Cause`, whether it's a failure, defect, interruption, or a
|
|
1555
|
+
* combination of these.
|
|
1556
|
+
*
|
|
1557
|
+
* The options parameter provides handlers for:
|
|
1558
|
+
* - `onEmpty`: Handles the case where the cause is `Empty`, meaning no errors
|
|
1559
|
+
* occurred.
|
|
1560
|
+
* - `onFail`: Processes a failure with an error of type `E`.
|
|
1561
|
+
* - `onDie`: Processes a defect (unexpected error).
|
|
1562
|
+
* - `onInterrupt`: Handles a fiber interruption, providing the `FiberId` of the
|
|
1563
|
+
* interruption.
|
|
1564
|
+
* - `onSequential`: Combines two sequential causes into a single value of type
|
|
1565
|
+
* `Z`.
|
|
1566
|
+
* - `onParallel`: Combines two parallel causes into a single value of type `Z`.
|
|
914
1567
|
*
|
|
915
1568
|
* @since 2.0.0
|
|
916
|
-
* @category
|
|
1569
|
+
* @category Matching
|
|
917
1570
|
*/
|
|
918
1571
|
export const match: {
|
|
919
1572
|
/**
|
|
920
|
-
*
|
|
1573
|
+
* Transforms a `Cause` into a single value using custom handlers for each
|
|
1574
|
+
* possible case.
|
|
1575
|
+
*
|
|
1576
|
+
* **Details**
|
|
1577
|
+
*
|
|
1578
|
+
* This function processes a `Cause` by applying a set of custom handlers to
|
|
1579
|
+
* each possible type of cause: `Empty`, `Fail`, `Die`, `Interrupt`,
|
|
1580
|
+
* `Sequential`, and `Parallel`. The result of this function is a single value
|
|
1581
|
+
* of type `Z`. This function allows you to define exactly how to handle each
|
|
1582
|
+
* part of a `Cause`, whether it's a failure, defect, interruption, or a
|
|
1583
|
+
* combination of these.
|
|
1584
|
+
*
|
|
1585
|
+
* The options parameter provides handlers for:
|
|
1586
|
+
* - `onEmpty`: Handles the case where the cause is `Empty`, meaning no errors
|
|
1587
|
+
* occurred.
|
|
1588
|
+
* - `onFail`: Processes a failure with an error of type `E`.
|
|
1589
|
+
* - `onDie`: Processes a defect (unexpected error).
|
|
1590
|
+
* - `onInterrupt`: Handles a fiber interruption, providing the `FiberId` of the
|
|
1591
|
+
* interruption.
|
|
1592
|
+
* - `onSequential`: Combines two sequential causes into a single value of type
|
|
1593
|
+
* `Z`.
|
|
1594
|
+
* - `onParallel`: Combines two parallel causes into a single value of type `Z`.
|
|
921
1595
|
*
|
|
922
1596
|
* @since 2.0.0
|
|
923
|
-
* @category
|
|
1597
|
+
* @category Matching
|
|
924
1598
|
*/
|
|
925
1599
|
<Z, E>(
|
|
926
1600
|
options: {
|
|
@@ -933,10 +1607,31 @@ export const match: {
|
|
|
933
1607
|
}
|
|
934
1608
|
): (self: Cause<E>) => Z
|
|
935
1609
|
/**
|
|
936
|
-
*
|
|
1610
|
+
* Transforms a `Cause` into a single value using custom handlers for each
|
|
1611
|
+
* possible case.
|
|
1612
|
+
*
|
|
1613
|
+
* **Details**
|
|
1614
|
+
*
|
|
1615
|
+
* This function processes a `Cause` by applying a set of custom handlers to
|
|
1616
|
+
* each possible type of cause: `Empty`, `Fail`, `Die`, `Interrupt`,
|
|
1617
|
+
* `Sequential`, and `Parallel`. The result of this function is a single value
|
|
1618
|
+
* of type `Z`. This function allows you to define exactly how to handle each
|
|
1619
|
+
* part of a `Cause`, whether it's a failure, defect, interruption, or a
|
|
1620
|
+
* combination of these.
|
|
1621
|
+
*
|
|
1622
|
+
* The options parameter provides handlers for:
|
|
1623
|
+
* - `onEmpty`: Handles the case where the cause is `Empty`, meaning no errors
|
|
1624
|
+
* occurred.
|
|
1625
|
+
* - `onFail`: Processes a failure with an error of type `E`.
|
|
1626
|
+
* - `onDie`: Processes a defect (unexpected error).
|
|
1627
|
+
* - `onInterrupt`: Handles a fiber interruption, providing the `FiberId` of the
|
|
1628
|
+
* interruption.
|
|
1629
|
+
* - `onSequential`: Combines two sequential causes into a single value of type
|
|
1630
|
+
* `Z`.
|
|
1631
|
+
* - `onParallel`: Combines two parallel causes into a single value of type `Z`.
|
|
937
1632
|
*
|
|
938
1633
|
* @since 2.0.0
|
|
939
|
-
* @category
|
|
1634
|
+
* @category Matching
|
|
940
1635
|
*/
|
|
941
1636
|
<Z, E>(
|
|
942
1637
|
self: Cause<E>,
|
|
@@ -952,27 +1647,81 @@ export const match: {
|
|
|
952
1647
|
} = internal.match
|
|
953
1648
|
|
|
954
1649
|
/**
|
|
955
|
-
*
|
|
956
|
-
*
|
|
1650
|
+
* Combines all parts of a `Cause` into a single value by starting with an
|
|
1651
|
+
* initial value.
|
|
1652
|
+
*
|
|
1653
|
+
* **Details**
|
|
1654
|
+
*
|
|
1655
|
+
* This function processes a `Cause` by starting with an initial value (`zero`)
|
|
1656
|
+
* and applying a custom function (`pf`) to combine all elements of the `Cause`
|
|
1657
|
+
* into a single result of type `Z`. The custom function determines how each
|
|
1658
|
+
* part of the `Cause` contributes to the final result. The function can return
|
|
1659
|
+
* an `Option` to either continue combining values or skip specific parts of the
|
|
1660
|
+
* `Cause`.
|
|
1661
|
+
*
|
|
1662
|
+
* This function is useful for tasks such as:
|
|
1663
|
+
* - Aggregating error messages from a `Cause` into a single string.
|
|
1664
|
+
* - Summarizing the structure of a `Cause` into a simplified result.
|
|
1665
|
+
* - Filtering or processing only specific parts of a `Cause`.
|
|
1666
|
+
*
|
|
1667
|
+
* The reduction proceeds in a top-down manner, visiting all nodes in the
|
|
1668
|
+
* `Cause` structure. This gives you complete control over how each part of the
|
|
1669
|
+
* `Cause` contributes to the final result.
|
|
957
1670
|
*
|
|
958
1671
|
* @since 2.0.0
|
|
959
|
-
* @category
|
|
1672
|
+
* @category Reducing
|
|
960
1673
|
*/
|
|
961
1674
|
export const reduce: {
|
|
962
1675
|
/**
|
|
963
|
-
*
|
|
964
|
-
*
|
|
1676
|
+
* Combines all parts of a `Cause` into a single value by starting with an
|
|
1677
|
+
* initial value.
|
|
1678
|
+
*
|
|
1679
|
+
* **Details**
|
|
1680
|
+
*
|
|
1681
|
+
* This function processes a `Cause` by starting with an initial value (`zero`)
|
|
1682
|
+
* and applying a custom function (`pf`) to combine all elements of the `Cause`
|
|
1683
|
+
* into a single result of type `Z`. The custom function determines how each
|
|
1684
|
+
* part of the `Cause` contributes to the final result. The function can return
|
|
1685
|
+
* an `Option` to either continue combining values or skip specific parts of the
|
|
1686
|
+
* `Cause`.
|
|
1687
|
+
*
|
|
1688
|
+
* This function is useful for tasks such as:
|
|
1689
|
+
* - Aggregating error messages from a `Cause` into a single string.
|
|
1690
|
+
* - Summarizing the structure of a `Cause` into a simplified result.
|
|
1691
|
+
* - Filtering or processing only specific parts of a `Cause`.
|
|
1692
|
+
*
|
|
1693
|
+
* The reduction proceeds in a top-down manner, visiting all nodes in the
|
|
1694
|
+
* `Cause` structure. This gives you complete control over how each part of the
|
|
1695
|
+
* `Cause` contributes to the final result.
|
|
965
1696
|
*
|
|
966
1697
|
* @since 2.0.0
|
|
967
|
-
* @category
|
|
1698
|
+
* @category Reducing
|
|
968
1699
|
*/
|
|
969
1700
|
<Z, E>(zero: Z, pf: (accumulator: Z, cause: Cause<E>) => Option.Option<Z>): (self: Cause<E>) => Z
|
|
970
1701
|
/**
|
|
971
|
-
*
|
|
972
|
-
*
|
|
1702
|
+
* Combines all parts of a `Cause` into a single value by starting with an
|
|
1703
|
+
* initial value.
|
|
1704
|
+
*
|
|
1705
|
+
* **Details**
|
|
1706
|
+
*
|
|
1707
|
+
* This function processes a `Cause` by starting with an initial value (`zero`)
|
|
1708
|
+
* and applying a custom function (`pf`) to combine all elements of the `Cause`
|
|
1709
|
+
* into a single result of type `Z`. The custom function determines how each
|
|
1710
|
+
* part of the `Cause` contributes to the final result. The function can return
|
|
1711
|
+
* an `Option` to either continue combining values or skip specific parts of the
|
|
1712
|
+
* `Cause`.
|
|
1713
|
+
*
|
|
1714
|
+
* This function is useful for tasks such as:
|
|
1715
|
+
* - Aggregating error messages from a `Cause` into a single string.
|
|
1716
|
+
* - Summarizing the structure of a `Cause` into a simplified result.
|
|
1717
|
+
* - Filtering or processing only specific parts of a `Cause`.
|
|
1718
|
+
*
|
|
1719
|
+
* The reduction proceeds in a top-down manner, visiting all nodes in the
|
|
1720
|
+
* `Cause` structure. This gives you complete control over how each part of the
|
|
1721
|
+
* `Cause` contributes to the final result.
|
|
973
1722
|
*
|
|
974
1723
|
* @since 2.0.0
|
|
975
|
-
* @category
|
|
1724
|
+
* @category Reducing
|
|
976
1725
|
*/
|
|
977
1726
|
<Z, E>(
|
|
978
1727
|
self: Cause<E>,
|
|
@@ -982,109 +1731,182 @@ export const reduce: {
|
|
|
982
1731
|
} = internal.reduce
|
|
983
1732
|
|
|
984
1733
|
/**
|
|
985
|
-
*
|
|
986
|
-
*
|
|
1734
|
+
* Combines all parts of a `Cause` into a single value using a custom reducer
|
|
1735
|
+
* and a context.
|
|
1736
|
+
*
|
|
1737
|
+
* **Details**
|
|
1738
|
+
*
|
|
1739
|
+
* This function allows you to reduce a `Cause` into a single value of type `Z`
|
|
1740
|
+
* using a custom `CauseReducer`. A `CauseReducer` provides methods to handle
|
|
1741
|
+
* specific parts of the `Cause`, such as failures, defects, or interruptions.
|
|
1742
|
+
* Additionally, this function provides access to a `context` value, which can
|
|
1743
|
+
* be used to carry information or maintain state during the reduction process.
|
|
1744
|
+
*
|
|
1745
|
+
* This is particularly useful when the reduction process needs additional
|
|
1746
|
+
* context or configuration, such as:
|
|
1747
|
+
* - Aggregating error details with dynamic formatting.
|
|
1748
|
+
* - Collecting logs or statistics about the `Cause`.
|
|
1749
|
+
* - Performing stateful transformations based on the `context`.
|
|
1750
|
+
*
|
|
1751
|
+
* @see {@link reduce} To reduce a `Cause` without additional context.
|
|
987
1752
|
*
|
|
988
1753
|
* @since 2.0.0
|
|
989
|
-
* @category
|
|
1754
|
+
* @category Reducing
|
|
990
1755
|
*/
|
|
991
1756
|
export const reduceWithContext: {
|
|
992
1757
|
/**
|
|
993
|
-
*
|
|
994
|
-
*
|
|
1758
|
+
* Combines all parts of a `Cause` into a single value using a custom reducer
|
|
1759
|
+
* and a context.
|
|
1760
|
+
*
|
|
1761
|
+
* **Details**
|
|
1762
|
+
*
|
|
1763
|
+
* This function allows you to reduce a `Cause` into a single value of type `Z`
|
|
1764
|
+
* using a custom `CauseReducer`. A `CauseReducer` provides methods to handle
|
|
1765
|
+
* specific parts of the `Cause`, such as failures, defects, or interruptions.
|
|
1766
|
+
* Additionally, this function provides access to a `context` value, which can
|
|
1767
|
+
* be used to carry information or maintain state during the reduction process.
|
|
1768
|
+
*
|
|
1769
|
+
* This is particularly useful when the reduction process needs additional
|
|
1770
|
+
* context or configuration, such as:
|
|
1771
|
+
* - Aggregating error details with dynamic formatting.
|
|
1772
|
+
* - Collecting logs or statistics about the `Cause`.
|
|
1773
|
+
* - Performing stateful transformations based on the `context`.
|
|
1774
|
+
*
|
|
1775
|
+
* @see {@link reduce} To reduce a `Cause` without additional context.
|
|
995
1776
|
*
|
|
996
1777
|
* @since 2.0.0
|
|
997
|
-
* @category
|
|
1778
|
+
* @category Reducing
|
|
998
1779
|
*/
|
|
999
1780
|
<C, E, Z>(context: C, reducer: CauseReducer<C, E, Z>): (self: Cause<E>) => Z
|
|
1000
1781
|
/**
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1782
|
+
* Combines all parts of a `Cause` into a single value using a custom reducer
|
|
1783
|
+
* and a context.
|
|
1784
|
+
*
|
|
1785
|
+
* **Details**
|
|
1786
|
+
*
|
|
1787
|
+
* This function allows you to reduce a `Cause` into a single value of type `Z`
|
|
1788
|
+
* using a custom `CauseReducer`. A `CauseReducer` provides methods to handle
|
|
1789
|
+
* specific parts of the `Cause`, such as failures, defects, or interruptions.
|
|
1790
|
+
* Additionally, this function provides access to a `context` value, which can
|
|
1791
|
+
* be used to carry information or maintain state during the reduction process.
|
|
1792
|
+
*
|
|
1793
|
+
* This is particularly useful when the reduction process needs additional
|
|
1794
|
+
* context or configuration, such as:
|
|
1795
|
+
* - Aggregating error details with dynamic formatting.
|
|
1796
|
+
* - Collecting logs or statistics about the `Cause`.
|
|
1797
|
+
* - Performing stateful transformations based on the `context`.
|
|
1798
|
+
*
|
|
1799
|
+
* @see {@link reduce} To reduce a `Cause` without additional context.
|
|
1003
1800
|
*
|
|
1004
1801
|
* @since 2.0.0
|
|
1005
|
-
* @category
|
|
1802
|
+
* @category Reducing
|
|
1006
1803
|
*/
|
|
1007
1804
|
<C, E, Z>(self: Cause<E>, context: C, reducer: CauseReducer<C, E, Z>): Z
|
|
1008
1805
|
} = internal.reduceWithContext
|
|
1009
1806
|
|
|
1010
1807
|
/**
|
|
1011
|
-
*
|
|
1808
|
+
* Creates an error that indicates a `Fiber` was interrupted.
|
|
1809
|
+
*
|
|
1810
|
+
* **Details**
|
|
1811
|
+
*
|
|
1812
|
+
* This function constructs an `InterruptedException` recognized by the Effect
|
|
1813
|
+
* runtime. It is usually thrown or returned when a fiber's execution is
|
|
1814
|
+
* interrupted by external events or by another fiber. This is particularly
|
|
1815
|
+
* helpful in concurrent programs where fibers may halt each other before
|
|
1816
|
+
* completion.
|
|
1012
1817
|
*
|
|
1013
1818
|
* @since 2.0.0
|
|
1014
|
-
* @category
|
|
1819
|
+
* @category Errors
|
|
1015
1820
|
*/
|
|
1016
1821
|
export const InterruptedException: new(message?: string | undefined) => InterruptedException = core.InterruptedException
|
|
1017
1822
|
|
|
1018
1823
|
/**
|
|
1019
|
-
*
|
|
1020
|
-
* otherwise.
|
|
1824
|
+
* Checks if a given unknown value is an `InterruptedException`.
|
|
1021
1825
|
*
|
|
1022
1826
|
* @since 2.0.0
|
|
1023
|
-
* @category
|
|
1827
|
+
* @category Guards
|
|
1024
1828
|
*/
|
|
1025
1829
|
export const isInterruptedException: (u: unknown) => u is InterruptedException = core.isInterruptedException
|
|
1026
1830
|
|
|
1027
1831
|
/**
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1832
|
+
* Creates an error indicating an invalid method argument.
|
|
1833
|
+
*
|
|
1834
|
+
* **Details**
|
|
1835
|
+
*
|
|
1836
|
+
* This function constructs an `IllegalArgumentException`. It is typically
|
|
1837
|
+
* thrown or returned when an operation receives improper inputs, such as
|
|
1838
|
+
* out-of-range values or invalid object states.
|
|
1030
1839
|
*
|
|
1031
1840
|
* @since 2.0.0
|
|
1032
|
-
* @category
|
|
1841
|
+
* @category Errors
|
|
1033
1842
|
*/
|
|
1034
1843
|
export const IllegalArgumentException: new(message?: string | undefined) => IllegalArgumentException =
|
|
1035
1844
|
core.IllegalArgumentException
|
|
1036
1845
|
|
|
1037
1846
|
/**
|
|
1038
|
-
*
|
|
1039
|
-
* otherwise.
|
|
1847
|
+
* Checks if a given unknown value is an `IllegalArgumentException`.
|
|
1040
1848
|
*
|
|
1041
1849
|
* @since 2.0.0
|
|
1042
|
-
* @category
|
|
1850
|
+
* @category Guards
|
|
1043
1851
|
*/
|
|
1044
1852
|
export const isIllegalArgumentException: (u: unknown) => u is IllegalArgumentException = core.isIllegalArgumentException
|
|
1045
1853
|
|
|
1046
1854
|
/**
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1855
|
+
* Creates an error indicating a missing element.
|
|
1856
|
+
*
|
|
1857
|
+
* **Details**
|
|
1858
|
+
*
|
|
1859
|
+
* This function constructs a `NoSuchElementException`. It helps you clearly
|
|
1860
|
+
* communicate that a required element is unavailable.
|
|
1049
1861
|
*
|
|
1050
1862
|
* @since 2.0.0
|
|
1051
|
-
* @category
|
|
1863
|
+
* @category Errors
|
|
1052
1864
|
*/
|
|
1053
1865
|
export const NoSuchElementException: new(message?: string | undefined) => NoSuchElementException =
|
|
1054
1866
|
core.NoSuchElementException
|
|
1055
1867
|
|
|
1056
1868
|
/**
|
|
1057
|
-
*
|
|
1058
|
-
* otherwise.
|
|
1869
|
+
* Checks if a given unknown value is a `NoSuchElementException`.
|
|
1059
1870
|
*
|
|
1060
1871
|
* @since 2.0.0
|
|
1061
|
-
* @category
|
|
1872
|
+
* @category Guards
|
|
1062
1873
|
*/
|
|
1063
1874
|
export const isNoSuchElementException: (u: unknown) => u is NoSuchElementException = core.isNoSuchElementException
|
|
1064
1875
|
|
|
1065
1876
|
/**
|
|
1066
|
-
*
|
|
1877
|
+
* Creates an error for general runtime errors.
|
|
1878
|
+
*
|
|
1879
|
+
* **Details**
|
|
1880
|
+
*
|
|
1881
|
+
* This function constructs a `RuntimeException`, for errors that occur at
|
|
1882
|
+
* runtime but are not specifically typed or categorized as interruptions,
|
|
1883
|
+
* missing elements, or invalid arguments. It helps unify a wide range of
|
|
1884
|
+
* unexpected conditions under a single, recognizable error type.
|
|
1067
1885
|
*
|
|
1068
1886
|
* @since 2.0.0
|
|
1069
|
-
* @category
|
|
1887
|
+
* @category Errors
|
|
1070
1888
|
*/
|
|
1071
1889
|
export const RuntimeException: new(message?: string | undefined) => RuntimeException = core.RuntimeException
|
|
1072
1890
|
|
|
1073
1891
|
/**
|
|
1074
|
-
*
|
|
1075
|
-
* otherwise.
|
|
1892
|
+
* Checks if a given unknown value is a `RuntimeException`.
|
|
1076
1893
|
*
|
|
1077
1894
|
* @since 2.0.0
|
|
1078
|
-
* @category
|
|
1895
|
+
* @category Guards
|
|
1079
1896
|
*/
|
|
1080
1897
|
export const isRuntimeException: (u: unknown) => u is RuntimeException = core.isRuntimeException
|
|
1081
1898
|
|
|
1082
1899
|
/**
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1900
|
+
* Creates an error for operations that exceed their expected time.
|
|
1901
|
+
*
|
|
1902
|
+
* **Details**
|
|
1903
|
+
*
|
|
1904
|
+
* This function constructs a `TimeoutException`. It is typically used to signal
|
|
1905
|
+
* that an operation or fiber did not complete within a designated time limit,
|
|
1906
|
+
* allowing you to handle slow or hanging processes.
|
|
1085
1907
|
*
|
|
1086
1908
|
* @since 2.0.0
|
|
1087
|
-
* @category
|
|
1909
|
+
* @category Errors
|
|
1088
1910
|
*/
|
|
1089
1911
|
export const TimeoutException: new(message?: string | undefined) => TimeoutException = core.TimeoutException
|
|
1090
1912
|
|
|
@@ -1117,70 +1939,102 @@ export const TimeoutException: new(message?: string | undefined) => TimeoutExcep
|
|
|
1117
1939
|
* promises or external APIs.
|
|
1118
1940
|
*
|
|
1119
1941
|
* @since 2.0.0
|
|
1120
|
-
* @category
|
|
1942
|
+
* @category Errors
|
|
1121
1943
|
*/
|
|
1122
1944
|
export const UnknownException: new(error: unknown, message?: string | undefined) => UnknownException =
|
|
1123
1945
|
core.UnknownException
|
|
1124
1946
|
|
|
1125
1947
|
/**
|
|
1126
|
-
*
|
|
1127
|
-
* otherwise.
|
|
1948
|
+
* Checks if a given unknown value is an `UnknownException`.
|
|
1128
1949
|
*
|
|
1129
1950
|
* @since 2.0.0
|
|
1130
|
-
* @category
|
|
1951
|
+
* @category Guards
|
|
1131
1952
|
*/
|
|
1132
1953
|
export const isUnknownException: (u: unknown) => u is UnknownException = core.isUnknownException
|
|
1133
1954
|
|
|
1134
1955
|
/**
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1956
|
+
* Creates an error indicating resource capacity has been exceeded.
|
|
1957
|
+
*
|
|
1958
|
+
* **Details**
|
|
1959
|
+
*
|
|
1960
|
+
* This function constructs an `ExceededCapacityException`, signifying that an
|
|
1961
|
+
* operation or resource usage surpassed established limits. This can be
|
|
1962
|
+
* essential for concurrency or resource management situations, ensuring your
|
|
1963
|
+
* application doesn't go beyond acceptable thresholds.
|
|
1137
1964
|
*
|
|
1138
1965
|
* @since 3.5.0
|
|
1139
|
-
* @category
|
|
1966
|
+
* @category Errors
|
|
1140
1967
|
*/
|
|
1141
1968
|
export const ExceededCapacityException: new(message?: string | undefined) => ExceededCapacityException =
|
|
1142
1969
|
core.ExceededCapacityException
|
|
1143
1970
|
|
|
1144
1971
|
/**
|
|
1145
|
-
*
|
|
1146
|
-
* otherwise.
|
|
1972
|
+
* Checks if a given unknown value is an `ExceededCapacityException`.
|
|
1147
1973
|
*
|
|
1148
1974
|
* @since 3.5.0
|
|
1149
|
-
* @category
|
|
1975
|
+
* @category Guards
|
|
1150
1976
|
*/
|
|
1151
1977
|
export const isExceededCapacityException: (u: unknown) => u is ExceededCapacityException =
|
|
1152
1978
|
core.isExceededCapacityException
|
|
1153
1979
|
|
|
1154
1980
|
/**
|
|
1155
|
-
*
|
|
1981
|
+
* Converts a `Cause` into a human-readable string.
|
|
1982
|
+
*
|
|
1983
|
+
* **Details**
|
|
1984
|
+
*
|
|
1985
|
+
* This function pretty-prints the entire `Cause`, including any failures,
|
|
1986
|
+
* defects, and interruptions. It can be especially helpful for logging,
|
|
1987
|
+
* debugging, or displaying structured errors to users.
|
|
1988
|
+
*
|
|
1989
|
+
* You can optionally pass `options` to configure how the error cause is
|
|
1990
|
+
* rendered. By default, it includes essential details of all errors in the
|
|
1991
|
+
* `Cause`.
|
|
1992
|
+
*
|
|
1993
|
+
* @see {@link prettyErrors} Get a list of `PrettyError` objects instead of a single string.
|
|
1156
1994
|
*
|
|
1157
1995
|
* @since 2.0.0
|
|
1158
|
-
* @category
|
|
1996
|
+
* @category Formatting
|
|
1159
1997
|
*/
|
|
1160
1998
|
export const pretty: <E>(cause: Cause<E>, options?: {
|
|
1161
1999
|
readonly renderErrorCause?: boolean | undefined
|
|
1162
2000
|
}) => string = internal.pretty
|
|
1163
2001
|
|
|
1164
2002
|
/**
|
|
2003
|
+
* A shape for prettified errors, optionally including a source span.
|
|
2004
|
+
*
|
|
1165
2005
|
* @since 3.2.0
|
|
1166
|
-
* @category
|
|
2006
|
+
* @category Models
|
|
1167
2007
|
*/
|
|
1168
2008
|
export interface PrettyError extends Error {
|
|
1169
2009
|
readonly span: Span | undefined
|
|
1170
2010
|
}
|
|
1171
2011
|
|
|
1172
2012
|
/**
|
|
1173
|
-
* Returns
|
|
2013
|
+
* Returns a list of prettified errors (`PrettyError`) from a `Cause`.
|
|
2014
|
+
*
|
|
2015
|
+
* **Details**
|
|
2016
|
+
*
|
|
2017
|
+
* This function inspects the entire `Cause` and produces an array of
|
|
2018
|
+
* `PrettyError` objects. Each object may include additional metadata, such as a
|
|
2019
|
+
* `Span`, to provide deeper insights into where and how the error occurred.
|
|
1174
2020
|
*
|
|
1175
2021
|
* @since 3.2.0
|
|
1176
|
-
* @category
|
|
2022
|
+
* @category Formatting
|
|
1177
2023
|
*/
|
|
1178
2024
|
export const prettyErrors: <E>(cause: Cause<E>) => Array<PrettyError> = internal.prettyErrors
|
|
1179
2025
|
|
|
1180
2026
|
/**
|
|
1181
|
-
*
|
|
2027
|
+
* Retrieves the original, unproxied error instance from an error object.
|
|
2028
|
+
*
|
|
2029
|
+
* **Details**
|
|
2030
|
+
*
|
|
2031
|
+
* This function returns the underlying error object without any
|
|
2032
|
+
* library-specific wrapping or proxying that might occur during error handling.
|
|
2033
|
+
* This can be essential if you need direct access to the error's native
|
|
2034
|
+
* properties, such as stack traces or custom data fields, for detailed
|
|
2035
|
+
* debugging or integration with external systems.
|
|
1182
2036
|
*
|
|
1183
2037
|
* @since 2.0.0
|
|
1184
|
-
* @category
|
|
2038
|
+
* @category Errors
|
|
1185
2039
|
*/
|
|
1186
2040
|
export const originalError: <E>(obj: E) => E = core.originalInstance
|