Errors are typically indicated by a non-zero integer value. Within a program/library, which is the main focus here, error return values are negative. For a program, error exit values are positive. In both cases, a zero value indicates success.
Even in Python, exceptions are not always the best way to do things. Sometimes returning an error code or similar is appropriate. In such situations, wherever one lands on the question of using something like
Error instead of integer return values for errors, the approach is worth considering.
Error is not always appropriate, but it does make one think about the merits of how and why things are done as they are.
- 2019-02-20: the base
Errorclass has been enhanced to support an error code
- 2019-01-26: added
perror_exit(); other updates
- 2018-01-20: renamed
erroto avoid possible name conflict
- 2017-11-08: the section on double assignment was added.