• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URLyBird 1.2.1 - Exceptions thrown from suncertify.db.Data

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

In my implementation of suncertify.db.DBAccess some of the methods contain synchronized code, and in some places I use the Object.wait() method that throws InterruptedException which is a checked exception. Also I call methods of RandomAccessFile that throw IOException - checked as well.

On the other hand the interface allows only RecordNotFoundException, SecurityException and DuplicateKeyException to be thrown from some of the methods. IMO none of them is a good choice to chain the InterruptedException or IOException in.

To workaround this I created a new exception type - DataRuntimeException that extends RuntimeException, and by definition can be thrown from any method.

Is this a good solution from the design point of view??

Cheers
Krzysiek
[ September 22, 2005: Message edited by: Krzysiek Hycnar ]
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have URLyBird 1.3.3 and did a similar thing:


However, I made sure the specify in the Javadoc contract of each method that does this the exact conditions under which this exception is thrown.
I chained the original exception in my DatabaseException.
Before throwing the exception I also did a .
 
Krzysiek Hycnar
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds good, but the fact both of us came up with the same solution does not automatically mean it's a good practice

Krzsiek
 
Ronald Wouters
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to read the following:

Runtime Exception (Wrap IOException)

Andrew says

Lots of candidates have wrapped the IOException in their own RuntimeException and passed, so you should be able to as well.



If you do a search on RuntimeException and Andrews member id you will find other interesting answers.

Regards,
Ronald Wouters
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use the same logic, even if I am not agree 100%. I think that the warp IOException (a checked exception) in to a RunTime (unckecked) is not such a good technique, by example if you have a slappy implemetation and you forget to catch the exception the whole application may crash if you just deal with a exceptional condition - but if you are "force" to check the exception you may "remenber" how to react in a exceptional condition.


Regards,
Mihai
 
This tiny ad is wafer thin:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic