Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/nperez0111/bookhive. Track your books, share your shelves, see what others are reading bookhive.buzz
atproto bluesky books bookshelf goodreads management-system
Something went wrong. Try again.
637 B · 19 lines
TypeScript
1234567891011121314151617181920/** * Catches thrown errors, stores them on the context for wide-event logging, then rethrows. * Mount after wide-event middleware so that when a route throws, we set c.requestError before * wide-event's finally runs. Handlers that catch and return 5xx should call c.set('requestError', e) * so the request log includes the error. */import type { MiddlewareHandler } from "hono";import type { AppEnv } from "../context";
export function errorCaptureMiddleware(): MiddlewareHandler<AppEnv> { return async (c, next) => { try { await next(); } catch (e) { c.set("requestError", e); throw e; } };}