Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLyBird: Adding new exceptions to the DBAccess interface

 
Michael Fisherman
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Michael Fisherman
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic