• 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

Exception handling questions

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Sorry new to exception handling, currently doing URLyBird project, and have 2 questiions.
(1)
If someone has a method in an interface like following say,
"public String[] read(int recNo) throws RecordNotFoundException"
If an error is declared in method like this, does that mean this method does not catch the exception but rather propogates it upwards to whoever is calling it?
(2)
For the project, if 1 creates their own errors do they have choice of either extending the exception or runtimeException class?
Thanks.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

1) such a method signature means: method can throw a RecordNotFoundException (and so the method itself is not handling it, the code where this method is called, should handle it or propagate it too).

2) extending Exception or extending RuntimeException is your own decision. In my assignment RNFE was a checked exception.

Kind regards,
Roel
 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roel. They were the responses I was hoping for.
reply
    Bookmark Topic Watch Topic
  • New Topic