Php Laravel未捕获异常
我试图从包中的中间件捕获异常:Php Laravel未捕获异常,php,laravel-5,exception-handling,jwt,Php,Laravel 5,Exception Handling,Jwt,我试图从包中的中间件捕获异常: public function authenticate(Request $request) { $this->checkForToken($request); try { if (! $this->auth->parseToken()->authenticate()) { throw new UnauthorizedHttpException('jwt-auth', 'User n
public function authenticate(Request $request)
{
$this->checkForToken($request);
try {
if (! $this->auth->parseToken()->authenticate()) {
throw new UnauthorizedHttpException('jwt-auth', 'User not found');
}
} catch (JWTException $e) {
throw new UnauthorizedHttpException('jwt-auth', $e->getMessage(), $e, $e->getCode());
}
}
我尝试捕获异常处理程序:
public function render($request, Exception $exception)
{
//dd($exception);
if ($exception instanceof UnauthorizedHttpException) {
return response()->json($exception->getMessage(), $exception->getStatusCode());
}
return parent::render($request, $exception);
}
但一点也没有。例外情况的dd如下:
UnauthorizedHttpException {#231 ▼
-statusCode: 401
-headers: array:1 [▶]
#message: "Token has expired"
#code: 0
#file: "/home/vagrant/codementor/vendor/tymon/jwt- auth/src/Http/Middleware/BaseMiddleware.php"
#line: 74
-previous: TokenExpiredException {#237 ▶}
trace: {▶}
}
哪个laravel版本5?它没有响应json?