Delphi / Object Pascal · Exception

EAssertionFailed Exception

What does EAssertionFailed Exception mean in Delphi / Object Pascal?

Raised by the Assert procedure when the boolean condition passed to it evaluates False, but only in code compiled with the $ASSERTIONS ON directive, the default in debug configurations. It's meant to catch violations of invariants the developer believes should always hold.

EAssertionFailed ExceptionDelphi (VCL) · Delphi (FireMonkey)

Condition

Raised by the Assert procedure when the boolean condition passed to it evaluates False, but only in code compiled with the $ASSERTIONS ON directive, the default in debug configurations. It's meant to catch violations of invariants the developer believes should always hold.

Fix

Treat a failing assertion as a real bug to fix rather than something to silence - if it fires during testing, the code has reached a state the author considered impossible. Don't ship builds where you still want assertions to catch regressions with $ASSERTIONS OFF.

Related exception