Should we write catch(Exception e) for every try catch block in java -


my question should have catch(exception e) every try - catch block. knowing catch exceptions .... type of coding recommended in java or should catch exceptions known occur.

consider below example.

 try {      //something  } catch (numberformatexception ne) {      //do  } catch (exception e) {      log.error(e);  } 

no. not practice. identify exceptions thrown before implementation. catch exceptions throwing method.

thoroughly unit test code , identify them.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -