RFC: Change what assert does on error
Walter Bright
newshound2 at digitalmars.com
Wed Jul 2 07:58:01 UTC 2025
Currently, the behavior of an assert error can be set with the command line:
Behavior on assert/boundscheck/finalswitch failure:
=[h|help|?] List information on all available choices
=D Usual D behavior of throwing an AssertError
=C Call the C runtime library assert failure function
=halt Halt the program execution (very lightweight)
=context Use D assert with context information (when available)
Note that the =D behavior really means calling the onAssertError() function in
core.exception:
https://dlang.org/phobos/core_exception.html#.onAssertError
which can will call (*_assertHAndler)() if that has been set by calling
assertHandler(), otherwise it will throw AssertError. _assertHandler is a global
symbol, not thread-local.
https://dlang.org/phobos/core_exception.html#.assertHandler
I know, this is over-engineered and poorly documented, but it is very flexible.
More information about the Digitalmars-d
mailing list