Effect CommunityEC
Effect Community2y ago
14 replies
Rory

Understanding Error Attribution in Stack Traces

I think I'm missing something fundamental. How do I get attribution on where in my code caused an error in a stack trace? For example, I have an error and the entire stacktrace is

ResponseError: StatusCode error (404 PATCH https://foo.io/v2/bar/null): non 2xx status code
    at orFailWith (/node_modules/.pnpm/@effect+platform@0.48.24_@effect+schema@0.64.18_effect@2.4.17_ws@8.16.0/node_modules/@effect/platform/src/internal/http/client.ts:460:9)
    at Ur.effect_instruction_i0 (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/core-effect.ts:640:101)
    at my.Sync (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/fiberRuntime.ts:1076:22)
    at f (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/fiberRuntime.ts:1308:52)
    at Object.context (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/tracer.ts:91:19)
    at my.runLoop (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/fiberRuntime.ts:1298:28)
    at my.evaluateEffect (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/fiberRuntime.ts:891:27)
    at my.evaluateMessageWhileSuspended (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/fiberRuntime.ts:859:14)
    at my.drainQueueOnCurrentThread (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/fiberRuntime.ts:621:18)
    at Array.run (/node_modules/.pnpm/effect@2.4.17/node_modules/effect/src/internal/fiberRuntime.ts:1345:10) 


I know where in the code it at from intuition, a client is failing with a filterStatusOk in a yield* pipeline like
  return yield* _(
    foo.req,
    request.appendUrl(`/bar/${barId}`),
    request.setMethod('PATCH'),
    body,
    andThen(foo.cl),
    Effect.scoped,
    Effect.withSpan("Foo.updateBar")
  );


Though none of that is in the error. How do I connect these pieces?
This feels similar to the issue that happens sometimes with unhandled promise rejections, where the error is trapped in the promise runtime and doesn't have outer context on where it happened.
Was this page helpful?