Effect CommunityEC
Effect Community3y ago
6 replies
ste.bl

Struggling with Stack Tracing in Effect Program

Hi, new to effect. Struggling with a stack tracing problem, hoping to get some insight.

I've modeled the parts failing in my program to look like the example here - https://github.com/Effect-TS/io/issues/438

import { Effect, Either, pipe } from "effect";

const someUtilityFunction = () => Either.left(new Error("utility failed"));

const someUtilityEffect = () =>
  pipe(Effect.succeed({}), Effect.flatMap(someUtilityFunction));

const doA = Effect.withSpan("doA")(
  Effect.promise(async () => console.log("did some async A"))
);

const program = Effect.withSpan("program")(
  pipe(
    doA,
    // Pick one or the other
    Effect.flatMap(() => Effect.withSpan("wrapFunction")(someUtilityFunction())),
    // Effect.flatMap(() => Effect.withSpan("wrapEffect")(someUtilityEffect()))
  )
);

void Effect.runPromise(program);
Was this page helpful?