Re:Where Everything Went Wrong: Error Handling and Error Mes...
by why_Mr_Anderson on Friday February 19, 2021 @05:24AM
(#26191492)
Because all systems try to handle several kinds of unexpected behavior in the exactly the same way
- invalid arguments (e.g. 'x == null')
- code logic (e.g. 'if (x.salary < 0) ...')
- external errors (e.g. 'out of memory')
I'd argue that only the 3rd kind is actually 'exception', it's completely out of program's control.
Code contracts are wonderful way of dealing with 1st and 2nd kind, sadly they didn't catch up and remains mostly unknown. They are vastly superior to tests and also serve as much better way to document intent of the code, how the author expected the code to work.
I'd argue that only the 3rd kind is actually 'exception', it's completely out of program's control.
Code contracts are wonderful way of dealing with 1st and 2nd kind, sadly they didn't catch up and remains mostly unknown. They are vastly superior to tests and also serve as much better way to document intent of the code, how the author expected the code to work.