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

Mapping Exceptions

 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to know if it is considered a good practice to catch different exceptions and rethrow them as a particular exception. For example, in the code below, I use a class that provides "data services" to the client. It has two constructors, one for local access, and one for remote access. The latter can throw 4 different types of exceptions, and I just rethrow them as my own exception class.
Is that a good design for this particular asignment? How about in general?
Thanks,
Eugene Kononov.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a system like this, it is a good idea to take certain exceptions rewrap them in an "Application" type exception for the client to handle.
I did the same thing, however I wrapped them all into a DatabaseException, since that type of Exception was already created for this app.
But I like your approach and suggest sticking to it.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic