App has no styled 500/fatal-error page — ErrorHandler is wired into essentially nothing #105

Open
opened 2026-09-01 00:21:13 -04:00 by jared · 0 comments
Owner

Severity: Medium

Confirmed by grep: ErrorHandler::init() has exactly one caller app-wide (api/get_template.php). index.php never calls it. ErrorHandler's shutdown handler is well-designed — catches E_ERROR/E_PARSE/E_CORE_ERROR/E_COMPILE_ERROR via error_get_last() and returns a clean JSON 500 — but since it's never registered for page views (or 32 of 33 API endpoints, a related gap already filed separately), a genuine PHP fatal during a page render (out-of-memory, an unrecoverable TypeError, etc.) falls through to PHP's raw default handling: whatever display_errors's server-wide ini default is determines whether the visitor sees a raw stack trace or a silently truncated blank page. There is no app-level 500 response in either case — no styled error page, no JSON fallback.

Fix: Register ErrorHandler::init() (or a page-view-appropriate variant that renders a styled HTML error page rather than JSON) at the top of index.php, and wire it into the remaining API endpoints per the already-filed related issue.

**Severity:** Medium Confirmed by grep: `ErrorHandler::init()` has exactly one caller app-wide (`api/get_template.php`). `index.php` never calls it. `ErrorHandler`'s shutdown handler is well-designed — catches `E_ERROR`/`E_PARSE`/`E_CORE_ERROR`/`E_COMPILE_ERROR` via `error_get_last()` and returns a clean JSON 500 — but since it's never registered for page views (or 32 of 33 API endpoints, a related gap already filed separately), a genuine PHP fatal during a page render (out-of-memory, an unrecoverable `TypeError`, etc.) falls through to PHP's raw default handling: whatever `display_errors`'s server-wide ini default is determines whether the visitor sees a raw stack trace or a silently truncated blank page. There is no app-level 500 response in either case — no styled error page, no JSON fallback. **Fix:** Register `ErrorHandler::init()` (or a page-view-appropriate variant that renders a styled HTML error page rather than JSON) at the top of `index.php`, and wire it into the remaining API endpoints per the already-filed related issue.
jared added the priority/mediumreliability labels 2026-09-08 10:15:51 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/tinker_tickets#105