Open NNBMon opened 7 years ago
I have this issue also. I try to catch in Handler.php but still return default from vendor. Awww.
Same question. Laravel 5.5
ββββββββ
Update:
I have solved the problem. The reason is I used dingo/api which took over the exception handler.
So I custom a handler at AppServiceProvider@register.
\API::error(function (\Tymon\JWTAuth\Exceptions\TokenExpiredException $exception) {
return response()->json([
'status_code' => 403,
'message' => $exception->getMessage()
], 200);
});
Hello guys. I need help for this. I wrote this codes in Handler.php that is not working :
public function render($request, Exception $exception) { console.log('Log here'); $exceptionClass = get_class($exception); $exceptionMessage = $exception->getMessage(); $exceptionCode = $exception->getCode();
switch ($exceptionClass) { case 'Tymon\JWTAuth\Exceptions\TokenExpiredException': return response()->json(['expired token'], 401); break; case 'Tymon\JWTAuth\Exceptions\TokenInvalidException': return response()->json(['invalid token'], 401); break; case 'Tymon\JWTAuth\Exceptions\JWTException': return response()->json(['general JWT error'], 500); break; default: return response()->json([$exceptionMessage], $exceptionCode); break; } return parent::render($request, $exception); }
But it's not show console.log('Log here') not called. I'm thinking any exception jwt not called render function. Give me this exception {"error":"token_not_provided"} printed. Sorry for my english :)