java - Catching several exceptions and rethrowing a general exception -


I am using reflection to add a data from a third-party library to a private variable within a client I am The way there are four different exceptions, which can be thrown away; They are all related to reflection, and not all of them are likely to be. I'm working hard on class and variables. I feel that no class has been found or an error has not been entered, unless the library is upgraded someday and changes quite a bit.

I do not want to declare four of these exceptions for my collar handle. He will never see them. I just want to catch all of these and another exception has been called "error of a Java reflection", it is possible that the library was upgraded incompatible with this method and changed. Is there a standard Java exception I can throw, which only indicates a normal reflection error? Should I define my own? Or would it be good to just declare that this method will remove all possible reflection exceptions?

You can change all exceptions to an AssertionError if you never expect them to be InvocationTargetException can be unblocked if you want to deal with a specific exception. If you want to throw the actual exception thrown by the method instead of invocationTargetException, you can use this move, but can be more deceptive than useful

 } hold (invocationTargetException e) {// throw any thread in the current thread (even if this is a check exception) threads Trillion (). Stop (e.getcause ()); }  

Comments