sfelix-martins /
json-exception-handler
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SMartins\JsonHandler; |
||
| 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); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 22 | $this->jsonApiResponse->setErrors($error); |
||
| 23 | } |
||
| 24 | } |
||
| 25 |