[java] application question

Started by
9 comments, last by pythonfan 21 years, 2 months ago
I normally have all my methods that may generate exceptions in one try block.


    //this is code that doesn''t handle the exception, but passes it//to the calling method to handle.//Good if the exception means that program execution can''t continue//because something very screwed up has happenedtry {  //call readLine, etc. Methods that throw IOException.} catch(IOException e) {  throw e;}        //This code just prints the stack trace (poor example of handling the exception).//You handle the exception, and don''t rethrow it if you think that the exception is trivial and can be handled locally.//you want program execution to continue.try {  //call readLine, etc. Methods that throw IOException.} catch(IOException e) {  e.printStackTrace();}    


That''s just my take. It probably isn''t best practice, but i can''t really see how else handle IOExceptions. IO is IMHO one of Java''s weakest points, thanks to its over use of checked exceptions.


Don''t know why it appeared on another thread..
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.

This topic is closed to new replies.

Advertisement