Error Message "Unhandled Exception: Assert failed"

BlitzMax Forums/BlitzMax Programming/Error Message "Unhandled Exception: Assert failed"

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

If you don't tell us which asserttion axactly fails, we'll have a hard time helping you.

An assert is a simple statement that checks if an expression is true, and throws an exception otherwise. It helps finding bugs, when you have a condition that *MUST* and is supposed to be true.
Here's an example:
Framework brl.basic
Import brl.standardio

Function PrintSqr(a)
	Assert (a > 0) Else "Can't compute square root of negative integer"
	Print Sqr(a)
End Function


PrintSqr(-10)
Because PrintSqr is called with a < 0, an exception is raised, and here the program stops. There could be no error message with the assert (just "Assert (a >= 0)"), but even then it's not that hard figuring what's wrong: the offending line should be highlighted in the editor.


A last note: such checks are used for debugging purpose, and thus are done only in a debug build.