| Author |
general qeustion about exceptions
|
Peter Aarum
Ranch Hand
Joined: Jan 14, 2010
Posts: 44
|
|
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
Bartender
Joined: Jul 19, 2004
Posts: 4349
|
|
(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
|
SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
|
 |
Prasanna Puttappa
Ranch Hand
Joined: Jul 21, 2003
Posts: 54
|
|
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.
|
~Prasanna (SCJP5.0, SCWCD5)
|
 |
Peter Aarum
Ranch Hand
Joined: Jan 14, 2010
Posts: 44
|
|
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
Joined: Jun 06, 2009
Posts: 220
|
|
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.
|
SCSA, OCA, SCJP 5.0, SCJD http://www.linkedin.com/in/carlosamorillo
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: general qeustion about exceptions
|
|
|