Integrating Effect with an existing Hono-based API and handling exceptions can be a bit tricky du...

Im trying to integrate effect into an existing Hono based API. Most of the route handlers translated to effects using a custom managed runtime but however not quite sure as to how to get it along with hono’s HttpException. Tried using custom Tagged error class similar to the one in Hono, but unable to propagate it to the top level onError and notFound handlers. Is there a way to propagate the error with its instance so we could have the normal onError handler as follows?


import { HTTPException } from 'hono/http-exception'

// ...

app.onError((err, c) => {
  if (err instanceof HTTPException) {
    // Get the custom response
    return err.getResponse()
  }
  // ...
})


The instance type of error in the above seems to be a ‘FiberFailure and can be detected via the isFiberFailure` helper but unable to validate it against the HttpException.
Was this page helpful?