• 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

Quick question on the B&S interface

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
She'll be back. I'm just gonna wait here. With this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic