Improve stack traces in debug output - #792
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves stack traces in debug output by including the exception origin point in the trace and making the display more comprehensive. The key changes refactor how stack traces are generated and displayed in error views.
- Introduces a new
getTrace()method that constructs a complete stack trace including the exception's origin point - Updates error views to use the new
stackTracevariable instead of callinggetTrace()directly on the throwable - Modifies
CodeDumper::dumpBacktraceFrame()to handle frames without function information (e.g., the exception origin)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| formwork/src/Panel/Controllers/ErrorsController.php | Adds getTrace() method to build complete stack trace with exception origin; passes stackTrace to views |
| formwork/src/Controllers/ErrorsController.php | Adds getTrace() method identical to Panel version for consistency across error controllers |
| panel/views/errors/error.php | Updates to use stackTrace variable; opens first frame by default; checks for both throwable and stackTrace |
| formwork/views/errors/partials/debug.php | Updates to use stackTrace variable; opens first frame by default |
| formwork/src/Debug/CodeDumper.php | Updates dumpBacktraceFrame() to handle frames without function info; adds validation and null-safe access to optional frame properties |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request improves error debugging and stack trace visualization across both the main application and the panel. The changes focus on consistently capturing and displaying the full stack trace for exceptions, refining trace formatting, and enhancing the robustness of code frame dumping.
Stack trace handling and display:
getTracemethod to bothformwork/src/Controllers/ErrorsController.phpandformwork/src/Panel/Controllers/ErrorsController.phpto generate a complete stack trace, including the exception origin, and handle edge cases forErrorandErrorExceptiontypes. This trace is now passed asstackTraceto error views. [1] [2]formwork/views/errors/partials/debug.phpandpanel/views/errors/error.php) to iterate over the newstackTracearray, ensuring all relevant frames are displayed and the first frame is expanded by default. [1] [2]Robustness and formatting improvements:
CodeDumper::dumpBacktraceFramemethod to validate frame structure, handle missing keys gracefully, and avoid errors when dumping code for incomplete frames.CodeDumper::dumpBacktraceFrameto prevent undefined index errors and ensure correct parameter display. [1] [2]CodeDumperfor a more compact and readable display.