java - why spring handles only unchecked exceptions -


i want know why spring handles unchecked exceptions..... can 1 explain reason behind .

spring using design patterns avoid checked exceptions ?

spring using design patterns avoid checked exceptions ?

not design pattern best practices exception handling.

consider below code:

public void consumeandforgetallexceptions(){     try {         ...some code throws exceptions     } catch (exception ex){         ex.printstacktrace();     } } 

what wrong code above?

once exception thrown, normal program execution suspended , control transferred catch block. catch block catches exception , suppresses it. execution of program continues after catch block, if nothing had happened.

how following?

public void somemethod() throws exception{ } 

this method blank one; not have code in it. how can blank method throw exceptions? java not stop doing this.

i want know why spring handles unchecked exceptions?

personally prefer unchecked exceptions declared in throws cause. hate having catch exceptions when i'm not interested in them. agree spec needs few more exception types, disagree should checked. frameworks rely on unchecked exceptions, not spring framework.

best practices designing api

  • if client can take alternate action recover exception, make checked exception.
  • if client cannot useful, make exception unchecked. useful, mean taking steps recover exception , not logging exception.

the java api has many unchecked exceptions, such nullpointerexception, illegalargumentexception, , illegalstateexception. prefer working standard exceptions provided in java rather creating own. make code easy understand , avoid increasing memory footprint of code.

see also:


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -