> For me - Checked Exceptions are a pain in the a.s.
> Hi,
>
[quoted text clipped - 10 lines]
> Ciao,
> Ingo
I'm not dishing exceptions, they are much better than error codes for
all of those good reasons we know.
However, I favour the 'write exception safe code' method, that is, dont
use or limit there use where possible. For example, we could simply
write a for loop with an incrementing int until we get an
OutofBoundException from the colloection, but we dont, we either use
iterators or loop while the index (int) is less than the collection size.
On those occasions where exceptions make sense, I make sure each layer
within the applications only expose their exceptions, not lower layer
exceptions. This means wrapping lower layer exceptions within new ones.
These new ones then add more context information to the lowlevel
exception.
Simplistic E.g.
a low level DB Exception - DBConnectionRefusedException("SQL: db not
contactable or offline - error code 1234")
Which would be wrapped by the model layer -
DatabaseConnectionFailureException("Unable to connect to Database
(MySystemDatabase)");
Ingo R. Homann - 20 Apr 2006 12:23 GMT
Hi,
> On those occasions where exceptions make sense, I make sure each layer
> within the applications only expose their exceptions, not lower layer
> exceptions. This means wrapping lower layer exceptions within new ones.
> These new ones then add more context information to the lowlevel
> exception.
Yes, that's how it is supposed to be.
But my question is: why do you want to wrap them in a
*Runtime*Exceptions? I think that makes it more difficult to decide
where to catch it (because the layer above does not necessarily know
that this exception is thrown)!
Ciao,
Ingo