@@ -3363,7 +3363,8 @@ exceptions
3363
3363
3364
3364
**type **: ``array ``
3365
3365
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:
3367
3368
3368
3369
.. configuration-block ::
3369
3370
@@ -3373,7 +3374,7 @@ Defines what ``log_level`` and ``status_code`` should be returned by exception c
3373
3374
framework :
3374
3375
exceptions :
3375
3376
Symfony\Component\HttpKernel\Exception\BadRequestHttpException :
3376
- log_level : debug
3377
+ log_level : ' debug'
3377
3378
status_code : 422
3378
3379
3379
3380
.. code-block :: xml
@@ -3401,35 +3402,34 @@ Defines what ``log_level`` and ``status_code`` should be returned by exception c
3401
3402
.. code-block :: php
3402
3403
3403
3404
// config/packages/exceptions.php
3405
+ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
3404
3406
use Symfony\Config\FrameworkConfig;
3405
3407
3406
3408
return static function (FrameworkConfig $framework) {
3407
3409
$framework
3408
- ->exceptions('Symfony\Component\HttpKernel\Exception\ BadRequestHttpException' )
3410
+ ->exceptions(BadRequestHttpException::class )
3409
3411
->log_level('debug');
3410
3412
3411
3413
$framework
3412
- ->exceptions('Symfony\Component\HttpKernel\Exception\ BadRequestHttpException' )
3414
+ ->exceptions(BadRequestHttpException::class )
3413
3415
->status_code(422);
3414
3416
;
3415
3417
};
3416
3418
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 ``:
3422
3421
3423
3422
.. code-block :: yaml
3424
3423
3425
3424
# config/packages/exceptions.yaml
3426
3425
framework :
3427
3426
exceptions :
3428
3427
Exception :
3429
- log_level : debug
3428
+ log_level : ' debug'
3430
3429
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'
3433
3433
status_code : 422
3434
3434
3435
3435
.. _`HTTP Host header attacks` : https://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html
0 commit comments