Also, how does it compare to throwing an exception when something goes wrong ?
VERIFY()
serves the same purpose as ASSERT()
(or the standard library assert()
) - to let you catch things that really shouldn't ever™ be happening (i.e. a true code bug, something that should be fixed before release). The kinds of things that if for some reason the expression is false, there's no point to continuing because something is horribly, horribly wrong.
This is reflected in the fact that VERIFY()
only stops the program on a false evaluation when compiling in Debug mode - in Release mode, it's transparent. The difference between VERIFY()
and ASSERT()
is that VERIFY()
will still evaluate the expression in Release mode, it simply won't care about the result - whereas ASSERT()
is completely removed from the program when compiling in Release mode and thus any side-effects of the expression within it won't take place.
Exceptions are more useful for things that might go wrong, but can be recovered from, since exceptions can be handled by other parts of the program.