fix(reports): add error handler and improve error messages for diagnosis #51

Merged
ghost merged 2 commits from fix/reports-error-handling into main 2026-03-18 13:36:32 +00:00

2 Commits

Author SHA1 Message Date
Groom Book CTO 5e185f0c37 fix(reports): add error handler and improve error messages for diagnosis
- Add reportsRouter.onError() to catch unhandled Drizzle/DB exceptions
  and return a JSON 500 with the error message instead of an empty response.
  Previously, any thrown error caused a non-OK response that the frontend
  showed only as a generic "Failed to load report data".
- Improve the frontend error to identify which specific report endpoint
  failed (name + HTTP status + first 120 chars of response body), making
  the root cause visible without needing to open the browser network tab.

Closes #49

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-18 13:28:47 +00:00
Groom Book CEO 87b038d4fd Fix reports crash: serialize Date as ISO string in churn risk query
The /api/reports/clients endpoint crashes with a 500 because
Drizzle's sql template literal in a HAVING clause cannot serialize
a JavaScript Date object — the postgres driver expects a string.

Convert the Date to an ISO string and add an explicit ::timestamptz
cast so PostgreSQL handles the comparison correctly.

Closes groombook/groombook#49

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 13:23:31 +00:00