Thread overview
AssertError or AssertException?
May 29, 2005
zwang
May 29, 2005
zwang
May 29, 2005
/dbc.html states:
"an assert in function bodies works by throwing an AssertException, which can be caught and handled."

/expression.html#AssertExpression says:
"Asserts evaluate the expression. If the result is false, an AssertError is thrown."

Which statement is correct?
How to catch an assertion exception?
May 29, 2005
"zwang" <nehzgnaw@gmail.com> wrote in message news:d7co51$2p14$1@digitaldaemon.com...
> /dbc.html states:
> "an assert in function bodies works by throwing an AssertException, which
> can be caught and handled."
>
> /expression.html#AssertExpression says:
> "Asserts evaluate the expression. If the result is false, an AssertError
> is thrown."
>
> Which statement is correct?
> How to catch an assertion exception?

dmd/src/phobos/std/asserterror.d has a definition for an AssertError class. So you'd use

catch(AssertError ae)
{

}

to catch an AssertError.

This also means that dbc.html has a typo.


May 29, 2005
Jarrett Billingsley wrote:
> "zwang" <nehzgnaw@gmail.com> wrote in message news:d7co51$2p14$1@digitaldaemon.com...
> 
>>/dbc.html states:
>>"an assert in function bodies works by throwing an AssertException, which can be caught and handled."
>>
>>/expression.html#AssertExpression says:
>>"Asserts evaluate the expression. If the result is false, an AssertError is thrown."
>>
>>Which statement is correct?
>>How to catch an assertion exception?
> 
> 
> dmd/src/phobos/std/asserterror.d has a definition for an AssertError class. So you'd use
> 
> catch(AssertError ae)
> {
> 
> }
> 
> to catch an AssertError.
> 
> This also means that dbc.html has a typo. 
> 
> 

Thanks!