How do I get Effect to throw an Error in pipe.
How do I get this propertly to throw an error?
import { Effect, pipe } from "effect";
const addServiceCharge = (amount: number): Effect.Effect<number, Error> =>
amount < 0
? Effect.fail(new Error("Amount cannot be negative"))
: Effect.succeed(amount + 1);
const fetchTransactionAmount = Effect.promise(() => Promise.resolve(-1));
const finalAmount = pipe(fetchTransactionAmount, Effect.map(addServiceCharge));
Effect.runPromise(finalAmount).then(console.log);import { Effect, pipe } from "effect";
const addServiceCharge = (amount: number): Effect.Effect<number, Error> =>
amount < 0
? Effect.fail(new Error("Amount cannot be negative"))
: Effect.succeed(amount + 1);
const fetchTransactionAmount = Effect.promise(() => Promise.resolve(-1));
const finalAmount = pipe(fetchTransactionAmount, Effect.map(addServiceCharge));
Effect.runPromise(finalAmount).then(console.log);