import { Effect, Option } from "effect"
import { program } from "./error-tracking"
// $ExpectType Effect<never, FooError | BarError, string>
const recovered = program.pipe(
Effect.catchSome((error) => {
if (error._tag === "FooError") {
return Option.some(Effect.succeed("Recovering from FooError"))
}
return Option.none()
})
)
In the code above, Effect.catchSome takes a function that examines the error (error) and decides whether to attempt recovery or not. If the error matches a specific condition, recovery can be attempted by returning
import { Effect, Option } from "effect"
import { program } from "./error-tracking"
// $ExpectType Effect<never, FooError | BarError, string>
const recovered = program.pipe(
Effect.catchSome((error) => {
if (error._tag === "FooError") {
return Option.some(Effect.succeed("Recovering from FooError"))
}
return Option.none()
})
)
In the code above, Effect.catchSome takes a function that examines the error (error) and decides whether to attempt recovery or not. If the error matches a specific condition, recovery can be attempted by returning