Skip to content

Commit 3fabd6f

Browse files
committed
Minor tweaks
1 parent 4023742 commit 3fabd6f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

reference/configuration/framework.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,7 +3363,8 @@ exceptions
33633363

33643364
**type**: ``array``
33653365

3366-
Defines what ``log_level`` and ``status_code`` should be returned by exception class:
3366+
Defines the :ref:`log level </logging>` and HTTP status code applied to the
3367+
exceptions that match the given exception class:
33673368

33683369
.. configuration-block::
33693370

@@ -3373,7 +3374,7 @@ Defines what ``log_level`` and ``status_code`` should be returned by exception c
33733374
framework:
33743375
exceptions:
33753376
Symfony\Component\HttpKernel\Exception\BadRequestHttpException:
3376-
log_level: debug
3377+
log_level: 'debug'
33773378
status_code: 422
33783379
33793380
.. code-block:: xml
@@ -3401,35 +3402,34 @@ Defines what ``log_level`` and ``status_code`` should be returned by exception c
34013402
.. code-block:: php
34023403
34033404
// config/packages/exceptions.php
3405+
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
34043406
use Symfony\Config\FrameworkConfig;
34053407
34063408
return static function (FrameworkConfig $framework) {
34073409
$framework
3408-
->exceptions('Symfony\Component\HttpKernel\Exception\BadRequestHttpException')
3410+
->exceptions(BadRequestHttpException::class)
34093411
->log_level('debug');
34103412
34113413
$framework
3412-
->exceptions('Symfony\Component\HttpKernel\Exception\BadRequestHttpException')
3414+
->exceptions(BadRequestHttpException::class)
34133415
->status_code(422);
34143416
;
34153417
};
34163418
3417-
.. note::
3418-
3419-
When defining exceptions the order is important as it will use the first exception that matches ``instanceof``
3420-
3421-
Example with ``\RuntimeException`` and ``\Exception``:
3419+
The order in which you configure exceptions is important because Symfony will
3420+
use the configuration of the first exception that matches ``instanceof``:
34223421

34233422
.. code-block:: yaml
34243423
34253424
# config/packages/exceptions.yaml
34263425
framework:
34273426
exceptions:
34283427
Exception:
3429-
log_level: debug
3428+
log_level: 'debug'
34303429
status_code: 404
3431-
RuntimeException: # This will never be used as \RuntimeException extends \Exception
3432-
log_level: debug
3430+
# The following configuration will never be used because \RuntimeException extends \Exception
3431+
RuntimeException:
3432+
log_level: 'debug'
34333433
status_code: 422
34343434
34353435
.. _`HTTP Host header attacks`: https://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html

0 commit comments

Comments
 (0)