Emmanuel Stapf [ES] wrote:
>> Can someone clarify something about exception philosophy in Eiffel?
>>
>> My understanding was, that if you let an exception propagate outside the
>> routine in which it occurred, you'd be sending information that is very
>> likely of no use to the caller, since it is not part of the failed
>> routine's contract.
>>
>> Have I got that right? Is it too extreme of an attitude to be practical?
>
> This is exactly the Eiffel philosophy. The caller will get a ROUTINE_FAILURE
> exception and if the caller really wants more details, then it can access the
> original exception.
>
> In practice, the original exception is good to have for submitting a bug report to
> the owner of the code that fails.
>
Manu,
no question about what you have said. But the point I wanted to make is
different.
If an exception is thrown, a corresponding rescue clause (if available)
is entered. If a rescue clause has been entered, you know already that a
ROUTINE_FAILURE has been thrown. Therefore having access to an exception
object of type ROUTINE_FAILURE doesn't give you additional information.
If the rescue clause can handle the exception (i.e. reestablish the
class invariant and retry or fail) without access to an exception
object, it is fine. But if it needs information about the exception
being thrown, it usually needs the original exception.
So my point was ergonomic: Why access the original exception object via
another exception object which is useless instead of having access to
the exception object of the original exception directly?
It would be interesting to get feedback if my thinking above is wrong or
if others had already made the same experience. Has anybody else already
used information in the ROUTINE_FAILURE exception object?
Regards
Helmut