What should happen when the assert message expression throws?

bauss jacobbauss at gmail.com
Thu Nov 24 08:23:22 UTC 2022


On Friday, 18 November 2022 at 13:18:39 UTC, Dennis wrote:
> My thoughts:
> - A wrong format string passed to `format` should be a runtime 
> error (if not caught at compile time), not an exception
>

I don't think it should be an error.

Format strings could come from user code and it shouldn't break 
the whole application because a user put a wrong format string in.

This is especially important in applications that can have 
multiple users interacting with it at the same time ex. a 
website, game server etc.

If it should be an error then there should be a way to validate a 
format string at runtime without attempting to call format.

Error should only be used for errors that aren't recoverable ex. 
out of memory, stackoverflow etc. it shouldn't be used for errors 
that are recoverable, that's exactly what exception is for.


More information about the Digitalmars-d mailing list