| @@ 7-24 (lines=18) @@ | ||
| 4 | ||
| 5 | use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
|
| 6 | ||
| 7 | trait BadRequestHttpHandler |
|
| 8 | { |
|
| 9 | public function badRequestHttpException(BadRequestHttpException $exception) |
|
| 10 | { |
|
| 11 | $statusCode = $exception->getStatusCode(); |
|
| 12 | ||
| 13 | $error = [[ |
|
| 14 | 'status' => $statusCode, |
|
| 15 | 'code' => $this->getCode('bad_request'), |
|
| 16 | 'source' => ['pointer' => $exception->getFile().':'.$exception->getLine()], |
|
| 17 | 'title' => 'bad_request', |
|
| 18 | 'detail' => $exception->getMessage(), |
|
| 19 | ]]; |
|
| 20 | ||
| 21 | $this->jsonApiResponse->setStatus($statusCode); |
|
| 22 | $this->jsonApiResponse->setErrors($error); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| @@ 7-24 (lines=18) @@ | ||
| 4 | ||
| 5 | use League\OAuth2\Server\Exception\OAuthServerException; |
|
| 6 | ||
| 7 | trait OAuthServerHandler |
|
| 8 | { |
|
| 9 | public function oAuthServerException(OAuthServerException $exception) |
|
| 10 | { |
|
| 11 | $statusCode = $exception->getHttpStatusCode(); |
|
| 12 | ||
| 13 | $error = [[ |
|
| 14 | 'status' => $statusCode, |
|
| 15 | 'code' => $this->getCode('not_found_http'), |
|
| 16 | 'source' => ['pointer' => $exception->getFile().':'.$exception->getLine()], |
|
| 17 | 'title' => $exception->getErrorType(), |
|
| 18 | 'detail' => $exception->getMessage(), |
|
| 19 | ]]; |
|
| 20 | ||
| 21 | $this->jsonApiResponse->setStatus($statusCode); |
|
| 22 | $this->jsonApiResponse->setErrors($error); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||