11..index ::
22 single: Error
33 single: Exception
4- single: Components;ErrorCatcher
4+ single: Components;ErrorRenderer
55
6- TheErrorCatcher Component
7- ==========================
6+ TheErrorRenderer Component
7+ ===========================
88
9- TheErrorCatcher component converts PHP errors and exceptions into other
9+ TheErrorRenderer component converts PHP errors and exceptions into other
1010 formats such as JSON and HTML and renders them.
1111
1212Installation
1313------------
1414
1515..code-block ::terminal
1616
17- $ composer require symfony/error-catcher
17+ $ composer require symfony/error-renderer
1818
1919 ..include ::/components/require_autoload.rst.inc
2020
2121Usage
2222-----
2323
24- TheErrorCatcher component provides several handlers and renderers to convert
24+ TheErrorRenderer component provides several handlers and renderers to convert
2525PHP errors and exceptions into other formats easier to debug when working with
2626HTTP applications.
2727
@@ -33,12 +33,12 @@ Handling PHP Errors and Exceptions
3333Enabling the Error Handler
3434~~~~~~~~~~~~~~~~~~~~~~~~~~
3535
36- The:class: `Symfony\\ Component\\ ErrorCatcher \\ ErrorHandler ` class catches PHP
36+ The:class: `Symfony\\ Component\\ ErrorRenderer \\ ErrorHandler ` class catches PHP
3737errors and converts them to exceptions (of class:phpclass: `ErrorException ` or
38- :class: `Symfony\\ Component\\ ErrorCatcher \\ Exception\\ FatalErrorException ` for
38+ :class: `Symfony\\ Component\\ ErrorRenderer \\ Exception\\ FatalErrorException ` for
3939PHP fatal errors)::
4040
41- use Symfony\Component\ErrorCatcher \ErrorHandler;
41+ use Symfony\Component\ErrorRenderer \ErrorHandler;
4242
4343 ErrorHandler::register();
4444
@@ -48,12 +48,12 @@ application uses the FrameworkBundle because it generates better error logs.
4848Enabling the Exception Handler
4949~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5050
51- The:class: `Symfony\\ Component\\ ErrorCatcher \\ ExceptionHandler ` class catches
51+ The:class: `Symfony\\ Component\\ ErrorRenderer \\ ExceptionHandler ` class catches
5252uncaught PHP exceptions and converts them to a nice PHP response. It is useful
5353in:ref: `debug mode <debug-mode >` to replace the default PHP/XDebug output with
5454something prettier and more useful::
5555
56- use Symfony\Component\ErrorCatcher \ExceptionHandler;
56+ use Symfony\Component\ErrorRenderer \ExceptionHandler;
5757
5858 ExceptionHandler::register();
5959
@@ -69,9 +69,9 @@ Rendering PHP Errors and Exceptions
6969Another feature provided by this component are the "error renderers", which
7070converts PHP errors and exceptions into other formats such as JSON and HTML::
7171
72- use Symfony\Component\ErrorCatcher \ErrorRenderer\ErrorRenderer;
73- use Symfony\Component\ErrorCatcher \ErrorRenderer\HtmlErrorRenderer;
74- use Symfony\Component\ErrorCatcher \ErrorRenderer\JsonErrorRenderer;
72+ use Symfony\Component\ErrorRenderer \ErrorRenderer\ErrorRenderer;
73+ use Symfony\Component\ErrorRenderer \ErrorRenderer\HtmlErrorRenderer;
74+ use Symfony\Component\ErrorRenderer \ErrorRenderer\JsonErrorRenderer;
7575
7676 $renderers = [
7777 new HtmlErrorRenderer(),
@@ -80,7 +80,7 @@ converts PHP errors and exceptions into other formats such as JSON and HTML::
8080 ];
8181 $errorFormatter = new ErrorFormatter($renderers);
8282
83- /** @var Symfony\Component\ErrorCatcher \Exception\FlattenException */
83+ /** @var Symfony\Component\ErrorRenderer \Exception\FlattenException */
8484 $exception = ...;
8585 /** @var Symfony\Component\HttpFoundation\Request */
8686 $request = ...;
@@ -96,28 +96,28 @@ Built-in Error Renderers
9696
9797This component provides error renderers for the most common needs:
9898
99- *:class: `Symfony\\ Component\\ ErrorCatcher \\ ErrorRenderer\\ HtmlErrorRenderer `
99+ *:class: `Symfony\\ Component\\ ErrorRenderer \\ ErrorRenderer\\ HtmlErrorRenderer `
100100 renders errors in HTML format;
101- *:class: `Symfony\\ Component\\ ErrorCatcher \\ ErrorRenderer\\ JsonErrorRenderer `
101+ *:class: `Symfony\\ Component\\ ErrorRenderer \\ ErrorRenderer\\ JsonErrorRenderer `
102102 renders errors in JSON format and it's compliant with the `RFC 7807 `_ standard;
103- *:class: `Symfony\\ Component\\ ErrorCatcher \\ ErrorRenderer\\ XmlErrorRenderer `
103+ *:class: `Symfony\\ Component\\ ErrorRenderer \\ ErrorRenderer\\ XmlErrorRenderer `
104104 renders errors in XML and Atom formats. It's compliant with the `RFC 7807 `_
105105 standard;
106- *:class: `Symfony\\ Component\\ ErrorCatcher \\ ErrorRenderer\\ TxtErrorRenderer `
106+ *:class: `Symfony\\ Component\\ ErrorRenderer \\ ErrorRenderer\\ TxtErrorRenderer `
107107 renders errors in plain text format.
108108
109109Adding a Custom Error Renderer
110110~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111111
112112Error renderers are PHP classes that implement the
113- :class: `Symfony\\ Component\\ ErrorCatcher \\ ErrorRenderer\\ ErrorRendererInterface `.
113+ :class: `Symfony\\ Component\\ ErrorRenderer \\ ErrorRenderer\\ ErrorRendererInterface `.
114114For example, if you need to render errors in `JSON-LD format `_, create this
115115class anywhere in your project::
116116
117- namespace App\ErrorCatcher ;
117+ namespace App\ErrorRenderer ;
118118
119- use Symfony\Component\ErrorCatcher \ErrorRenderer\ErrorRendererInterface;
120- use Symfony\Component\ErrorCatcher \Exception\FlattenException;
119+ use Symfony\Component\ErrorRenderer \ErrorRenderer\ErrorRendererInterface;
120+ use Symfony\Component\ErrorRenderer \Exception\FlattenException;
121121
122122 class JsonLdErrorRenderer implements ErrorRendererInterface
123123 {
170170
171171# config/services.yaml
172172services :
173- App\ErrorCatcher \JsonLdErrorRenderer :
173+ App\ErrorRenderer \JsonLdErrorRenderer :
174174arguments :['%kernel.debug%']
175175tags :['error_catcher.renderer']
176176
184184 https://symfony.com/schema/dic/services/services-1.0.xsd" >
185185
186186 <services >
187- <service id =" App\ErrorCatcher \JsonLdErrorRenderer" >
187+ <service id =" App\ErrorRenderer \JsonLdErrorRenderer" >
188188 <argument >true</argument >
189189 <tag name =" error_catcher.renderer" />
190190 </service >
194194 ..code-block ::php
195195
196196 // config/services.php
197- use App\ErrorCatcher \JsonLdErrorRenderer;
197+ use App\ErrorRenderer \JsonLdErrorRenderer;
198198
199199 $container->register(JsonLdErrorRenderer::class)
200200 ->setArguments([true]);