Handling Failures with Either in Effect: Why is the Fail on the Left?
hi guys why is the fail on the left:
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
}
})