Handling Specific Error Tags and Continuing Execution in Effect Workflow

Hello team,

How can I handle a specific error tag in an existing Effect workflow and continue the execution flow with a replacement value?

Specifically, given an Effect that performs multiple steps and can fail with tagged errors, I want to:
1. Catch a specific error tag from outside the workflow
2. Replace the failed step's value with a fix
3. Continue executing the remaining steps of the original workflow

Example:
// Existing workflow I can't modify
const workflow = Effect.gen(function* (_) {
  const step1 = yield* _(Effect.fail(new Step1Error("Failed")))
  const step2 = yield* _(Effect.succeed(`Processing ${step1}`))
  const step3 = yield* _(Effect.succeed("Done"))
  return { step1, step2, step3 }
})

// What I want to do (pseudo-code for illustration):
const handled = workflow.pipe(
  Effect.catchTagWith('Step1Error', () => 
    // How to provide replacement value and continue the workflow?
    // Rather than replacing the entire effect
  )
)


I don't have access to modify the original workflow's implementation - I need to handle this 'from the outside'.
Was this page helpful?