www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - AssertError or AssertException?

reply zwang <nehzgnaw gmail.com> writes:
/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
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"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
parent zwang <nehzgnaw gmail.com> writes:
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!
May 29 2005