Edited
There is no good default CLR exception that is suitable for this situation. You have to roll yourself. I get directly from the exception, since you probably do not want this error to mix with other types of errors.
There are situations when a program can recover from this seemingly fatal situation: if you can be sure that the problem in this class cannot spread elsewhere. This is, for example, when you use this class as part of a function that has no side effects. This may seem like a far-fetched example, but itโs not when you intentionally write or pack code so that it does not have side effects.
I donโt think you should do something decisive, like quitting the program (as suggested in another now deleted answer). As a class author, this is not your responsibility.
As the author of software using this class, I would like to be able to tell the user that something happened, try to save backup copies, log data, write material to databases ... you will get an image.
user180326
source share