Skip to content

Pre-release 4.2.117 → 4.2.116 — task 4.5 (error handling): v13 report/render API in the exception Handler - #89

Merged
agissept merged 1 commit into
masterfrom
pre-release/4.2.117
Oct 2, 2026
Merged

agissept merged 1 commit into
masterfrom
pre-release/4.2.117

Conversation

@oonid

@oonid oonid commented Sep 30, 2026 •

Copy link
Copy Markdown

Task 4.5, error handling — v13 report/render API in the exception Handler

Stacks on #88. The fork's exception Handler reports and renders the way v13's Foundation\Exceptions\Handler does. The app can then register its error handling through v13's API now, and after the flip bootstrap/app.php's withExceptions() hands the same registration to v13's own handler. So what gets rendered and reported doesn't change at the flip.

Changes

  • Illuminate\Exception\Handler, following v13's semantics:
    • Report:
      • reportable() returns a ReportableHandler (v13's class, added under v13's name). Its callback is matched by its first parameter's type, including union types. Returning false, or calling ->stop(), ends reporting.
      • dontReport(), stopIgnoring() and v13's internal don't-report list: HttpException, TokenMismatchException, ModelNotFoundException, ValidationException, Symfony's request exceptions, and the rest.
      • report() calls the exception's own report() if it has one, then the callbacks. Finally it logs the message, with the exception (and userId) as context.
    • Render:
      • render() calls the exception's own render() (or Responsable) first, then prepareException(): ModelNotFound → 404, TokenMismatch → 419 HttpException, and so on.
      • Then the renderable() callbacks run in registration order, and the first response wins.
      • An HttpResponseException answers with its response. Anything else falls back to the plain/debug displayers, as before.
    • Handling an exception:
      • handleException() reports, then renders the current request. If a callback throws, what it throws is displayed, as before.
      • The queue worker's ExceptionHandlerAdapter reports and renders through the same methods (it used handleConsole()).
  • Illuminate\Foundation\Configuration\Exceptions: v13's withExceptions() object, under v13's name, with render(), report(), dontReport() and stopIgnoring().
  • Removed: App::error(), pushError(), missing() and fatal(), and the newest-first handler list behind them. v13 has none of them. TinkerCommand's silencing handler becomes a render callback.
  • Tests:
    • HandlerTest is rewritten for the new API. It covers ordering, null fall-through, prepareException(), the request argument, HttpResponseException, the displayer fallbacks, logging, the don't-report lists, report callbacks and stop(), the exception's own report(), the Exceptions object and the worker adapter.
    • QueueForkBridgeTest expects report().

Not in this PR

  • App::down() (maintenance), and the App::before()/after() global filters, are the next slice.
  • The displayers and the Illuminate\Exception namespace stay until the flip, so illuminate/exception stays in replace.

Verification

  • Fork:
    • suite 286 green on PHPUnit 11.5.56, with no deprecations, notices or warnings;
    • ratchet green, every pattern at baseline.
  • Downstream: the dicoding app pair dicoding-dev/dicoding#5970 (feature/platform/framework-4.2.117-rc1) moves its App::error handlers onto this API. It ran with vendor installed exactly from its lock and the local SMTP sink on 127.0.0.1:1025:
    • Psalm (full project, no cache): no errors.
    • Unit suite: 8477 green.
    • Integration suite: all 2995 tests, including 8 new error-handling tests, run per directory. There are the same 5 failures as the 4.2.116 pair, and 196 skipped. No test is flagged risky.
    • A request through Application::handle() outside the testing environment renders the app's 404 page, and its JSON 404 for an api/ URL.
  • Checks ran in a cloud container without deck (PHP 8.4.26, MariaDB 10.11).

Tag

4.2.117 on 5c7de70a is not pushed; tag pushes are refused for this session.

🤖 Generated with Claude Code

https://claude.ai/code/session_0169SsatCE8LhaTsQTPiGtVo

@agissept
agissept added this pull request to stack #91 October 1, 2026 06:28
@agissept
agissept force-pushed the pre-release/4.2.117 branch 4 times, most recently from ee8fd0f to dfea34a Compare October 2, 2026 06:48
Base automatically changed from pre-release/4.2.116 to master October 2, 2026 06:54
@agissept
agissept marked this pull request as ready for review October 2, 2026 06:56
… 4.5)

The Handler reports and renders the way v13's Foundation Handler does,
so an app's error handling written against it keeps its meaning after
the flip:

- reportable() (a ReportableHandler: typed by its first parameter,
  false or stop() ends reporting), dontReport(), stopIgnoring() and
  v13's internal don't-report list. report() runs the exception's own
  report(), then the callbacks, then logs the message with the
  exception (and userId) as context.
- renderable() callbacks run in registration order, first response
  wins, after the exception's own render()/Responsable and
  prepareException() (ModelNotFound -> 404, TokenMismatch -> 419, ...).
  An HttpResponseException answers with its response; anything else
  falls back to the displayers, as before.
- handleException() reports, then renders the current request; the
  worker adapter reports and renders through the same methods.
- Foundation\Configuration\Exceptions, v13's withExceptions() object,
  with render/report/dontReport/stopIgnoring.
- App::error(), pushError(), missing() and fatal() go, with the
  newest-first handler list behind them: v13 has none of them.
  Tinker's silencing handler becomes a render callback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169SsatCE8LhaTsQTPiGtVo
@agissept
agissept force-pushed the pre-release/4.2.117 branch from dfea34a to 2ce12b3 Compare October 2, 2026 06:56
@agissept
agissept merged commit 71f5bad into master Oct 2, 2026
2 checks passed
@agissept
agissept deleted the pre-release/4.2.117 branch October 2, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants