| Author |
URLyBird: Adding new exceptions to the DBAccess interface
|
Michael Fisherman
Greenhorn
Joined: Oct 11, 2007
Posts: 18
|
|
Hello, I am working on the URLyBird project. The project gives you the function declarations within interface DBAccess. Here is one: public long [] findByCriteria(String [] criteria); Are we allowed to add our own exceptions to this declaration while still following the "must" requirements. i.e public long [] findByCriteria(String [] criteria) throws FieldMismatchException; where FieldMismatchException is my own defined exception residing in the suncertify.db package. If I have to stay true to the exact function declaration would throwing and catching Runtime exceptions in these functions work or make sense for a substitution ?
|
 |
Roberto Perillo
Bartender
Joined: Dec 28, 2007
Posts: 2212
|
|
Howdy, my buddy. Unfortunatelly, you can't add your exceptions to any of the interface methods. If you really feel like throwing an exception, you can throw RuntimeExceptions, since they are unchecked (without altering the interface). By the way, I also have the URLyBird project, but the signatures of the methods are different. For example, the signature of my findByCriteria() method is: public int [] find(String [] criteria) throws RecordNotFoundException; So, it is actually called find(). Just for curiosity, what is the version of your project?
|
Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
|
 |
Michael Fisherman
Greenhorn
Joined: Oct 11, 2007
Posts: 18
|
|
Hey there Thanks for your response. I guess I figured that I couldnt change/add to the function in any way, just wanted to make sure. The version that I have is 1.2.1
|
 |
Oguz Ozun
Greenhorn
Joined: May 10, 2007
Posts: 19
|
|
Originally posted by Roberto Perillo: Howdy, my buddy. Unfortunatelly, you can't add your exceptions to any of the interface methods. If you really feel like throwing an exception, you can throw RuntimeExceptions, since they are unchecked (without altering the interface). By the way, I also have the URLyBird project, but the signatures of the methods are different. For example, the signature of my findByCriteria() method is: public int [] find(String [] criteria) throws RecordNotFoundException; So, it is actually called find(). Just for curiosity, what is the version of your project?
Another option is wrapping your exception into allowed one.
|
 |
Roberto Perillo
Bartender
Joined: Dec 28, 2007
Posts: 2212
|
|
Originally posted by Oguz Ozun: Another option is wrapping your exception into allowed one.
I would be careful with that. For example, I wouldn't wrap a FieldMismatchException on a RecordNotFoundException, for example. It wouldn't be so cohesive. But, depending on the exception, yes, it would be an option too. By the way, the version of my project is URLyBird 1.3.1. That was it! [ February 26, 2008: Message edited by: Roberto Perillo ]
|
 |
 |
|
|
subject: URLyBird: Adding new exceptions to the DBAccess interface
|
|
|