File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Example applications selected and choices around Exception handling

 
Michael MacLynn
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Edward and Robert,

With respect to the exception handling section of the OCA Java SE 7 Programmer I Study Guide, does the book contain any advice about how to decide when to try to recover from exception conditions vs when to just write the error to the log (or System.err)?

In most of the introductory texts I've looked at, the exception examples simply write the errors to the console. I guess I'd like to see more realistic example applications showing good examples of exception handling. Can you comment on the sorts of examples used in this section of the book? Are books focusing on exam objectives a little constrained in this area?

thanks!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33691
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgetting about the cert or books for a minute, there are basically three things you can do with an exception:

  • log it (ideally to a log file rather than the console)
  • throw it and let the caller deal with it (or not)
  • have special logic like a database rollback or business logic to actually handle the exception


  • It sounds like you are asking about #3. That's tough to cover in a book because it is so dependent on the actual logic you are working with.
     
    Jacek Laskowski
    Ranch Hand
    Posts: 42
    IntelliJ IDE Mac OS X Scala
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Jeanne,

    I could think of the 4th approach: proceed with no care of any (Runtime/unchecked) exceptions be thrown in a given scope. Nobody will care until the exception will ultimately get thrown
     
    Michael MacLynn
    Greenhorn
    Posts: 4
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Jeanne,

    It sounds like you are asking about #3. That's tough to cover in a book because it is so dependent on the actual logic you are working with.


    Yes I'd probably to better to look at the exception handling in the code for a good quality open source java application like Tomcat than in textbooks.

    Thanks for taking the time to post a response.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic