• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Exception Handling and Throwing

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In my assignment (B&S 2.3.3) my interface is called DBMain and the implementing class is called Data. In my Data class I handle exceptions such as IOExceptions and re throw them as DataException which is a RuntimeException.

I've add the DataException as part of the throws clause like so...
Data.java


The DBMain.java was specified like so...


I'm wondering if I'll be breaking any "must" requirements in the assignment by adding this Exception. What does everyone else think? Has anyone done this?

Cheers,
Matt.
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

the general convention is that RuntimeException and subclasses shall not be declared to be thrown in the signature. Some people disagree, but I like this convention and I follow it.

In your case you should follow it either way, because otherwise you would take an unnecessary (though low) risk of an automatic failure.

Conan
 
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Matt -

I think you're asking for trouble by adding the second exception. While you may not automatically fail for this change (though you may, I'm not sure), you would probably lose points.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic