Level 104
Throwable is an interface implemented by Error and Exception, so it should improve fault handling
1 like
What should i use in try catch in catch section Throwable or Exception:
/**
* JWt Authorization
*
* @return JsonResponse
*/
public function jwtAuthorization(): JsonResponse
{
$response = ['result' => [], 'errors' => []];
$httpStatusCode = Response::HTTP_OK;
try {
$_TOKEN = $this->genJwt(\request());
$jws = $this->serializer->unserialize($_TOKEN);
$isAuthentic = $this->jwtTokenService->verifyAuthenticity($jws);
$isNotExpired = $this->jwtTokenService->verifyExpiration($jws);
$response['result']['isAuthentic'] = $isAuthentic;
$response['result']['isNotExpired'] = $isNotExpired;
} catch (\Throwable $e) {
$httpStatusCode = Response::HTTP_BAD_REQUEST;
$response['errors'][] = $e->getTrace();
}
return \response()->json($response, $httpStatusCode);
Throwable is an interface implemented by Error and Exception, so it should improve fault handling
Please or to participate in this conversation.