| Conditions | 4 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 3 | ||
| Bugs | 1 | Features | 2 |
| 1 | <?php |
||
| 33 | public function handle($request, Closure $next) |
||
| 34 | { |
||
| 35 | try { |
||
| 36 | $response = $next($request); |
||
| 37 | // Was an exception thrown? If so and available catch in our middleware |
||
| 38 | if (isset($response->exception) && $response->exception) { |
||
| 39 | throw $response->exception; |
||
| 40 | } |
||
| 41 | |||
| 42 | return $response; |
||
| 43 | } catch (OAuthException $e) { |
||
| 44 | $data = [ |
||
| 45 | 'error' => $e->errorType, |
||
| 46 | 'error_description' => $e->getMessage(), |
||
| 47 | ]; |
||
| 48 | |||
| 49 | return new JsonResponse($data, $e->httpStatusCode, $e->getHttpHeaders()); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | } |
||
| 53 |