This code works fine for me:
return ((ResponseStatusException) ex).getStatusCode().equals(HttpStatus.NOT_FOUND);