Re: Which exception to use here?
- From: Christian Schulte <nospam@xxxxxxxxxxxxxx>
- Date: Sat, 20 Mar 2010 22:21:41 +0100
Stefan Ram schrieb:
[...]
never be thrown in the first place (and if it happens:
indicate a programmer error, not a runtime failure in the
sense of a harddisk device failure or so). So:
What would be a good class to use instead of
»WhatToUseHereException« below?
java.lang.AssertionError probably if the div() method is specified to
_only_ throw the DivisionByZero exception for y == 0 and is never called
with y == 0 in the try block.
In your example you explicitly test y != 0 before calling div(). If the
DivisionByZero exception is thrown although y != 0, the div() method is
broken and there is no way to handle that without fixing that method.
.
- Follow-Ups:
- Re: Which exception to use here?
- From: Tom Anderson
- Re: Which exception to use here?
- Prev by Date: Re: Discrepancy in current hour
- Next by Date: Re: Discrepancy in current hour
- Previous by thread: Re: Which exception to use here?
- Next by thread: Re: Which exception to use here?
- Index(es):