-
-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Hi,
I noticed that my custom error logging wasn't working for errors thrown from within the React Router app. From what I can see it is currently not possible to use onError properly.
createHonoServer initializes a new Hono instance (see here):
const reactRouterApp = new Hono<E>({
strict: false,
});
Since no error handler is configured, this instance has Hono's default error handler (see here).
The reactRouterApp is then configured as route handler:
app.route(`${basename}`, reactRouterApp);
app.route(...) checks if the reactRouterApp's errorHandler is the default error handler (which it is) and then adopts that (see here):
app.routes.map((r) => {
let handler
if (app.errorHandler === errorHandler) { // 👈 here
handler = r.handler
} else {
handler = async (c: Context, next: Next) =>
(await compose([], app.errorHandler)(c, () => r.handler(c, next))).res
;(handler as any)[COMPOSED_HANDLER] = r.handler
}
subApp.#addRoute(r.method, r.path, handler)
})
Can you provide a way to configure onError for the reactRouterApp as well? Maybe just adopt the errorHandler from the app that can be passed into createHonoServer? That's at least how I expected it to work.
Apart from that, thanks for the great work with this library!