catch (InvalidCastException e) { // Perform some action here, and then throw a new exception. throw new YourCustomException("Put your error message here.", e); }