3 ms·
Every pre-, post-, and invariant condition violation represents a programming error, at an indeterminate point in the past, rendering the state of the computati
by ncmncm 6y ago
Every pre-, post-, and invariant condition violation represents a programming error, at an indeterminate point in the past, rendering the state of the computation unknown, and likely undefined, and definitely unrecoverable.
An exception, by definition, is to enable recovery from externally imposed events in a well-defined program state.
The only useful, meaningful response to discovering a contract violation is termination. Throwing an exception is the worst imaginable response.
- Bambo 6y agoThe exception throwing is a compromise, it allows you to view the stack trace in an IDE to find out which assertions failed.