Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Additional methods in Exceptions

 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my specs, Sun says the following about the unimplemented exceptions that their provided interface references (for example, like the RecordNotFoundException).

Each must have a zero argument constructor and a second constructor that takes a String that serves as the exception's description.

So...
1. Does this mean I can only have those 2 constructors? (they don't specifically say ONLY these constructors, but is it implied?)
2. Or can I add an additional one if needed? (I want to add one that takes both a String and a Throwable.)
Thanks.
TJ
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TJ,
You can add any other convenient constructors that you want to but you MUST provide the ones they specify or risk automatic failure. I added one to RecordNotFoundException that takes an int recNo argument. Exceptions are supposed to be convenient to build and use.
 
Terry Martinson
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ken. Good idea on the additional argument to RecordNotFoundException.
TJ
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic