This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Quick question on the B&S interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Quick question on the B&S interface" Watch "Quick question on the B&S interface" New topic
Author

Quick question on the B&S interface

Harjit Singh
Ranch Hand

Joined: Feb 01, 2007
Posts: 77
Hi there,

The interface which the B&S uses throws some exceptions. My Database layer actually has to throw IO exceptions. How can I handle that ? Can I add those exceptions to the interface methods or shall I throw run time exceptions ?

Thanks

- Harjit
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Hi,

you cannot modify the contract (your interface), so no you cannot throw your IOException.

What else then? subclass of the Exception type your Interface allows you... runtime exception... handling it at the db layer...
There are tones of threads on this subject..

The choices are not infinite, but they come down to design choices. If you search on the forum, you'll see the most common solution...
I think most of people choose to throw a runtime exception, which does not go against your contract..

Rgrds,
Alex
Musab Al-Rawi
Ranch Hand

Joined: Aug 06, 2007
Posts: 231
This topic has been discussed in several posts.
You search the forum, but as one of the options you can throw a RuntimeException or a subclass of RuntimeException, since the user can't do anything about it.


SCBCD - SCWCD - SCJD - SCJP - OCA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Quick question on the B&S interface
 
Similar Threads
Exception Handling behaviour
RemoteException Problem
Question on using return value and not.
JAX-RPC EJB End points doubt in xyzws
Can i modify the interface sun providing