[12.x] Display previous exceptions in error renderer #57372
Closed
+109
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Problem
When exceptions are wrapped with previous exceptions using the
$previous
parameter, the error page only shows the top-level exception. This makes debugging difficult as developers cannot see the full exception chain without diving into code, turning a simple one-minute debug into an hour-long investigation.As requested in #57366:
Solution
1. Exception Chain Traversal (Exception.php:277-301)
Added two new methods to the
Exception
class:previousExceptions()
- Traverses the entire exception chain using$exception->getPrevious()
until it returns null, collecting class, message, and code for eachhasPreviousExceptions()
- Checks if any previous exceptions exist2. New UI Component (previous-exceptions.blade.php)
Created a new Blade component that displays all previous exceptions in a section styled like the Exception Trace:
3. Template Integration
show.blade.php
to include the previous exceptions section between trace and queriesmarkdown.blade.php
to include previous exceptions in markdown exports for sharing/documentation4. Test Coverage
Added
testItCanRenderPreviousExceptions()
that verifies:Test Plan
getPrevious()
returns nullWhat This Fixes
Resolves #57366 - Exceptions rendering do not expose previous exceptions