#Spring security exception handling
9 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @south phoenix! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
catching specific JWT exceptions: ```java
try {
// Code that parses/validates JWT
} catch (ExpiredJwtException e) {
// Handle expired token
} catch (SignatureException e) {
// Handle invalid signature
} catch (MalformedJwtException e) {
// Handle invalid token
}
try {
username = jwtService.extractUsername(token);
} catch (ExpiredJwtException e) {
throw new BadCredentialsException("Expired jwt token", e);
} catch (SignatureException e) {
throw new BadCredentialsException("Corrupted jwt token signature", e);
} catch (MalformedJwtException e) {
throw new BadCredentialsException("Malformed jwt token", e);
} catch (Exception e) {
throw new BadCredentialsException("Invalid jwt token", e);
}
i have written like this
but it throws exception in the console and a long exception with the message is thrown on client
i want to throw response entity object and return message