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

B&S DBMain -- New Exceptions?

 
Kevin Conaway
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

Along with the supplied DBMain.java, my instructions also stated:

Any unimplemented exceptions in this interface must all be created as member classes of the X package. Each must have a zero argument constructor and a second constructor that takes a String that serves as the exceptions description.

Does this mean that I am allowed to modify DBMain.java such that it can throw new checked Exceptions? Or just stating that for the exceptions it DOES throw (RecordNotFound,DuplicateKey), I have to create them as it specifies?

Thanks,

Kevin
 
Leonid Shalit
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Kevin!
Adding new checked exception is changing method signature. It will stop other classes related on the same interface from working. (However, you can add unchecked exceptions) So don't do it. They are talking about RecordNotFound and DuplicateKey .
 
Kevin Conaway
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leonid,

Thanks for replying. I figured you can add unchecked exceptions, that feels like a bit of a hack to me though. I am trying to throw some kind of DataAccessException when an IOException occurs while physically reading or writing the database.

Kevin
 
Kevin Conaway
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading the archived threads and thinking about it myself, it seems there are 2 possible solutions:

- Subclass RecordNotFoundException and DuplicateKeyException for special case IOExceptions.

- Throw a special IOException that extends RuntimeException.

I went with the first and chained the original IOException to the special subclass. I think the exceptions were too important not to be checked.

Kevin
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic