From e67c314c46e7d48013fe4a591664d4e5008cf4e0 Mon Sep 17 00:00:00 2001 From: Victor Jack <67293106+thedon-dev@users.noreply.github.com> Date: Tue, 11 Aug 2026 13:27:41 +0100 Subject: [PATCH] fix(api): return standard error shape for unhandled public API 500s#809 --- apps/api/src/routes/v1/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/api/src/routes/v1/index.ts b/apps/api/src/routes/v1/index.ts index 14fafa13..c2875f29 100644 --- a/apps/api/src/routes/v1/index.ts +++ b/apps/api/src/routes/v1/index.ts @@ -1,9 +1,17 @@ +import * as Sentry from '@sentry/node'; + import { Hono } from '@api/utils/hono'; import { publicApiCors } from '@api/middlewares/cors'; +import { ErrorCodes, handlePublicApiError } from '@api/utils/errors'; import { v1AudienceRouter } from './audience'; import { v1CoursesRouter } from './courses'; export const v1Router = new Hono() .use('*', publicApiCors) .route('/audience', v1AudienceRouter) - .route('/courses', v1CoursesRouter); + .route('/courses', v1CoursesRouter) + .onError((err, c) => { + console.error('Public API error:', err); + Sentry.captureException(err); + return handlePublicApiError(c, err, 'Internal Server Error', ErrorCodes.INTERNAL_ERROR); + });