java - What is the best way to catch an IllegalArgumentException -


When would the best use of this type of exception occur, and is it properly hand-picked, like caught in the catch?

  hold (exception e)  

Or does it need to be clearly caught?

  hold (illegal authorization exception e)  

will be caught in advance - but it should not be as high as the bunch of other exceptions you actually want.

The second thing is better if you actually is to catch it ... but usually this indicates a bug in the calling code It is sometimes a case of another method which is thrown at illegal agreement exception at any given time, in high quality its arguments, etc. at any ideal time, collar There should be a way to validate the value before passing it, or call that version Take that which fails in a non-exceptionally manner (like TryParse in pattern .net, which is without Java in / code> parameters). This is not always the case, but whenever you get a invalid archive exception , it is worth to see if you check the values ​​before calling the method By doing so you can avoid it.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -