diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index ddaed96d025..9fd42aeb177 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -3316,6 +3316,80 @@ Defines the kind of workflow that is going to be created, which can be either a normal workflow or a state machine. Read :doc:`this article ` to know their differences. +exceptions +"""""""""" + +**type**: ``array`` + +Defines what ``log_level`` and ``status_code`` should be returned by exception class: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/exceptions.yaml + framework: + exceptions: + Symfony\Component\HttpKernel\Exception\BadRequestHttpException: + log_level: debug + status_code: 422 + + .. code-block:: xml + + + + + + + + + debug + 422 + + + + + + + .. code-block:: php + + // config/packages/exceptions.php + use Symfony\Config\FrameworkConfig; + + return static function (FrameworkConfig $framework) { + $framework + ->exceptions('Symfony\Component\HttpKernel\Exception\BadRequestHttpException') + ->log_level('debug'); + + $framework + ->exceptions('Symfony\Component\HttpKernel\Exception\BadRequestHttpException') + ->status_code(422); + ; + }; + +.. note:: + + When defining exceptions the order is important as it will use the first exception that matches ``instanceof`` + +Example with ``\RuntimeException`` and ``\Exception``: + +.. code-block:: yaml + + # config/packages/exceptions.yaml + framework: + exceptions: + Exception: + log_level: debug + status_code: 404 + RuntimeException: # This will never be used as \RuntimeException extends \Exception + log_level: debug + status_code: 422 + .. _`HTTP Host header attacks`: https://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html .. _`Security Advisory Blog post`: https://symfony.com/blog/security-releases-symfony-2-0-24-2-1-12-2-2-5-and-2-3-3-released#cve-2013-4752-request-gethost-poisoning .. _`Doctrine Cache`: https://www.doctrine-project.org/projects/doctrine-cache/en/current/index.html