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
Post a Comment