import { Effect, Either } from "effect"
import { program } from "./error-tracking"
const recovered = Effect.gen(function* () {
const failureOrSuccess = yield* Effect.either(program)
if (Either.isLeft(failureOrSuccess)) {
// failure case: you can extract the error from the `left` property
const error = failureOrSuccess.left
return `Recovering from ${error._tag}`
} else {
// success case: you can extract the value from the `right` property
return failureOrSuccess.right
}
})
import { Effect, Either } from "effect"
import { program } from "./error-tracking"
const recovered = Effect.gen(function* () {
const failureOrSuccess = yield* Effect.either(program)
if (Either.isLeft(failureOrSuccess)) {
// failure case: you can extract the error from the `left` property
const error = failureOrSuccess.left
return `Recovering from ${error._tag}`
} else {
// success case: you can extract the value from the `right` property
return failureOrSuccess.right
}
})