i working on java plugin framework.
i have written code in such way entrypoint function looks below (consider starting point, main function)
function entrypoint() { try{ //some code block subfunction1(); subfunction2(); } catch(exception e) {} catch(ioexception ioe) {} catch(nullpointerexception npe){} } function subfunction1() throws ioexception { //some code } function subfunction2() throws nullpointerexception { //some code } so idea is, sub functions throws specific exceptions major function , catch these exceptions in major functions , handling.
is way correct? if not please suggest better way.
the order of
catchstatements should changed. since firstcatchmatchexceptions, following 2 never triggered.an
npein cases unexpected , not recoverable. catching implies application able recover , run regardless. case?even if
nperecoverable, better practice check!= nullinstead of relying on exceptions command flow. conceptual reasons (exception-based command flow requires more code, less readable, intention unclear) performance reasons.all
exceptionsswallowed - no logging or rethrowing happens. way, no 1 know if , when goes wrong because there no exceptions logged. in cases, users, other developers , maintainers expect exceptions exceptional , therefore logged.
Comments
Post a Comment