I generally subclass RuntimeException for library code etc. There is one place where I swallow an exception:So, does 'S' in Ian S stand for Suess?int maxValues = Integer.MAX_VALUE; try { maxValues = Integer.parseInt( xmlElement.getAttribute("max") ); } catch( NumberFormatException nfe ) { //keep default. }Technically I should throw an IllegalArgumentException(nfe) or check for "", null, etc.Anyway. This is what I paste in and commit to CVS whenever I catch (pun intended) a fellow coder swallowing exceptions. It rarely happens un-explicated now.
*ahem*
/* Will no-one*/ } catch( Exception e /* ! */ ) { //No getMessage() shall we ever see, //No System.exit( THIS_SHOULD_NOT_BE ); //No RuntimeException( WONT_CATCH_ME ); //No closure for Exception e, //for our programmer, with little thought, //has left Exception e uncaught! }//Oh cruel bracket, how you limit the scope of his instance!*bows*Posted by: Ian S on April 30, 2003 11:00 PM
Comments