Skip to content

Commit 7333ffe

Browse files
authored
Write documentation section for handling errors within generators (#1281)
1 parent 191b5c8 commit 7333ffe

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

content/src/content/docs/docs/getting-started/using-generators.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ Key steps to follow when using `Effect.gen`:
8484
- Use `yield*` to handle effects
8585
- Return the final result
8686

87+
If any of the effects that you handle inside of the generator with `yield*`
88+
fail, then the generator will stop and exit with that failure.
89+
8790
<Aside type="caution" title="Required TypeScript Configuration">
8891
The generator API is only available when using the `downlevelIteration`
8992
flag or with a `target` of `"es2015"` or higher in your `tsconfig.json`
@@ -249,6 +252,8 @@ How does this affect your code? If you have several operations in sequence, once
249252

250253
In simpler terms, if something fails at any point, the program will stop right there and deliver the error to you.
251254

255+
If you don't want to stop on an error, you can use the `Effect.either` method to encapsulate the error in the [Either](/docs/data-types/either/) data type: see the [examples of managing expected errors](/docs/error-management/expected-errors/#either).
256+
252257
**Example** (Halting Execution at the First Error)
253258

254259
```ts twoslash

0 commit comments

Comments
 (0)