Retain Error Type with runPromise

I feel like I’m missing something really obvious here, so apologies if this is an incredibly dumb question.

I’m trying to introduce Effect into a legacy app, with a plan to slow the move the “edge” further out over time.

The boundary is a Promise-based function, so runPromise seemed the obvious solution.

However, our error handlers depend on instanceof and for the error thrown by runPromise this is FibreFailureImpl rather than our actual error class.

Is there a simple way or retaining the error type without wrapping my pipeline inside a Promise and using Effect.match to call resolve/reject.

i.e.

new Promise((resolve, reject) => pipe(
    …,
    Effect.match({
         onFailure: (error) => reject(error),
          onSuccess: () => resolve()
    }),
    Effect.runSync
))


It just feels like I’ve missed something fundamental as it’s quite a lot of boilerplate.
Was this page helpful?