AssertError

Lionello Lunesu lio at lunesu.remove.com
Thu Jan 4 07:24:09 PST 2007


Valery wrote:
> When I want to unittest the incorrect behaviour of a component, I
> often write something like
> 
> try {
>   // this code throws AssertError
> } catch (Error e) { }
> 
> What I really want is to catch AssertError instead of Error, but
> is is not in object nor elsewhere in phobos.
> 
> Is it possible to catch exactly AssertError ?

I think there's a reason it's not documented.. There's something very 
strange about wanting to catch an assert. There's no guarantee that the 
assert gets compiled in. It would by like wanting to catch a 
array-bounds error for, say, an invalid indexing like array[1000].

L.



More information about the Digitalmars-d mailing list