lundi 26 octobre 2015

How do you throw an instance of an Exception class created through reflection?

I am trying to create a function that throws an exception based on the type that you pass in.

private void myFunc(Class<?> exceptionType) {
   ...do some work...
   throw new exceptionOfTypeExceptionTypePassedIn(newMessage);
}

Can you do this?





Aucun commentaire:

Enregistrer un commentaire