sfelix-martins /
json-exception-handler
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SMartins\JsonHandler; |
||
| 4 | |||
| 5 | use Laravel\Passport\Exceptions\MissingScopeException; |
||
| 6 | |||
| 7 | trait MissingScopeHandler |
||
| 8 | { |
||
| 9 | public function missingScopeException(MissingScopeException $exception) |
||
| 10 | { |
||
| 11 | $error = [[ |
||
| 12 | 'status' => 403, |
||
| 13 | 'code' => $this->getCode('missing_scope'), |
||
| 14 | 'source' => ['pointer' => $exception->getFile().':'.$exception->getLine()], |
||
| 15 | 'title' => 'missing_scope', |
||
| 16 | 'detail' => $exception->getMessage(), |
||
| 17 | ]]; |
||
| 18 | |||
| 19 | $this->jsonApiResponse->setStatus(403); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 20 | $this->jsonApiResponse->setErrors($error); |
||
| 21 | } |
||
| 22 | } |
||
| 23 |