-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ErrorRenderer] Refactor and delegate serializing responsibility to the Serializer component #34288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4d3c31d
to
99f2631
Compare
@@ -18,7 +18,6 @@ Console | |||
Debug | |||
----- | |||
|
|||
* Deprecated the `Debug` class, use the one from the `ErrorRenderer` component instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[duplicated] the whole component is deprecated (mentioned two lines bellow)
@@ -57,7 +57,6 @@ Console | |||
Debug | |||
----- | |||
|
|||
* Removed the `Debug` class, use the one from the `ErrorRenderer` component instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -26,14 +26,14 @@ | |||
*/ | |||
class FlattenException extends LegacyFlattenException | |||
{ | |||
private $title; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor refactor for better name (it was introduced in 4.4)
1ae38b6
to
a13b9de
Compare
5bfb7b6
to
05f4b08
Compare
Ready for review! (Travis dep=high failures is normal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
public function normalize($exception, $format = null, array $context = []) | ||
{ | ||
if (!$exception instanceof FlattenException) { | ||
$exception = FlattenException::createFromThrowable($exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if ErrorRenderer is not installed?
} | ||
} | ||
``` | ||
|
||
Configure your rendering service tagging it with `error_renderer.renderer`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed from:
symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php
Line 35 in d5ba535
'error_renderer.renderer', |
closing in favor of #34312 |
…onent (nicolas-grekas, yceruto) This PR was merged into the 4.4 branch. Discussion ---------- [ErrorHandler] merge and remove the ErrorRenderer component | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This PR supersedes #34288. Here is what it does: - Merge the `ErrorRenderer` component into `ErrorHandler` - Add `ErrorRendererInterface::render(\Throwable $e): FlattenException` and refactor error renderers around it. - Add `FlattenException::setAsString()` to make the previous possible. - Add `CliErrorRenderer` to render error on the CLI too. This means `VarDumper` is now a required dependency of `ErrorHandler`. This paves the way to use it also for rendering HTML - the logic there is much more advanced than what `HtmlErrorRenderer` provides and ever should provide. - Make `BufferingLogger` map its collected logs to `error_log()` if they are not emptied before. - Remove some classes that are not needed anymore (`ErrorRenderer`, `ErrorRendererPass`, `HtmlErrorRendererInterface`) - Simplified the logic in `Debug::enable()` - nobody uses its arguments - Fix a few issues found meanwhile. With these changes, the component can be used standalone. One is now able to require only it, register it either with either `ErrorHandler::register()` or `Debug::enable()` and profit. Commits ------- d1bf1ca [ErrorHandler] help finish the PR 6c9157b [ErrorHandler] merge and remove the ErrorRenderer component
By default, the ErrorRenderer component will host only the HTML+JS error page, delegating the serialization of other formats to the Serializer component (if installed & serializer config is enabled). This will simplify the usage and integration with other third-party packages like API-Platform and FOSRestBundle.
Main changes:
ProblemNormalizer
to the Serializer component (RFC 7807 compliant),<Format>ErrorRenderer
and registration mechanism in favor of Serializer's normalizers (seeUPGRADE-4.4.md
changes),debug:error-renderer
command, it's no longer needed, as well as other classes.Related comment:
wdyt?