• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

general qeustion about exceptions

 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody!

I have a kind of general qeustion about exceptions. I use this aproach: for instance, the RandomAccessFile constructor throws FileNotFoundException. I wrap this exception in my facade with my own DatabaseAccessException to hide implementation to the next tier, the Service tier.

Your view on this?

Best ragards
Peter
 
Roel De Nijs
Sheriff
Posts: 10666
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(I did exactly the same, you should always hide implementation details, so you can easily switch from a flat file to a RDBMS for example)

Kind regards,
Roel
 
Prasanna Puttappa
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a correct approach in case you do not want to expose system exception to calling program. Similar approach is used when calling EJB methods from the client/business delegate classes. Instead of exposing system exceptions such as RemotException, CreateException to client you can throw custom application exception like ResourceNotAvaiableException.

 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Roel! You are tha man!

Thanks Prasanna as well (took long time writing message so...)

A releaf to know I am not off base totally

BR
Peter
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Good question ... So far the only Data class exception I have is InvalidDatabaseException for when I run into
a Database File Format problem reading the cookie, record flag, etc.

I didn't think of this case.


Thanks,

Carlos.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic