Mega Code Archive

 
Categories / Delphi / OOP
 

Assertions are not working

Does it seem that Assertions are not working? Do violate assertions not cause a 'break'? If an assertion is violated within a try..except block, and you simply eat the exceptions, then you will not see the violation. The reason is clear.. the assertion generates an EAssertionFailure exception which is eaten if you are running outside the IDE or in the IDE with try assert(false, 'Always a Violation'); myCode(); except on E:EMyException do ShowMessage('myCode() failed'); else Raise; // this line is important! end;