aspose file tools*
The moose likes Associate Certification (OCAJP 7) and the fly likes Example applications selected and choices around Exception handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7)
Bookmark "Example applications selected and choices around Exception handling" Watch "Example applications selected and choices around Exception handling" New topic
Author

Example applications selected and choices around Exception handling

Michael MacLynn
Greenhorn

Joined: Aug 11, 2010
Posts: 4
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29233
    
138

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.


    [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
    Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
    Jacek Laskowski
    Ranch Hand

    Joined: Nov 06, 2005
    Posts: 34

    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


    Jacek Laskowski - http://blog.japila.pl
    Michael MacLynn
    Greenhorn

    Joined: Aug 11, 2010
    Posts: 4
    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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Example applications selected and choices around Exception handling
     
    Similar Threads
    "Programming Scala" examples
    Objectives for the SCMAD exam are here!!
    Conversion of service specific exceptions to Runtime exceptions in WS.
    Spring Web Flow 2 Web Development
    JSP Tag Libraries