What should happen when the assert message expression throws?
Dukc
ajieskola at gmail.com
Sat Nov 19 08:11:45 UTC 2022
On Friday, 18 November 2022 at 12:36:14 UTC, RazvanN wrote:
> What do you think? Is deprecating having an assert message that
> may throw a severe restriction? Are there other rewrites that I
> am missing?
In my opinion the fix is clear. When the assertion handler at
DRuntime determines the assertion has failed, it should call the
error message generator (it is lazy IIRC) in a try/catch block.
If the generator throws an exception, the error message of
assertion failure should be something like `<FormatException
thrown while writing error message>`.
Should the error generation exception be the `.next` member of
`AssertError`? Probably, but I'm not sure.
If the message generator throws an unrecoverable error, that
should probably still mask the assert error. If a `RangeError`
masks `AssertError` it's unlikely to be a problem since neither
is likely to be caught and at least in my mind they're
essentially the same - a "bug detected" error.
More information about the Digitalmars-d
mailing list