JsonExceptionResponse::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
/*
5
 * This file is part of the package typo3/cms-digital-asset-management.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE file that was distributed with this source code.
9
 */
10
11
namespace TYPO3\CMS\DigitalAssetManagement\Http;
12
13
use TYPO3\CMS\Core\Http\JsonResponse;
14
15
/**
16
 * A response 400 object returned if controller
17
 * caught some exception and returns details.
18
 */
19
class JsonExceptionResponse extends JsonResponse
20
{
21
    public function __construct(\Exception $e)
22
    {
23
        $data = [
24
            'errorMessage' => $e->getMessage(),
25
            'errorCode' => $e->getCode(),
26
            'errorClass' => get_class($e),
27
        ];
28
        parent::__construct($data, 400);
29
    }
30
}
31