Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
Because the reality is that people don’t document errors (what exceptions can be raised by a method), don’t explicitly handle all the cases (how many times have you returned a 500 in a Flask app from missing an error type in your except block/missing an errorhandler), or don’t even think to put a try…except around fallible code (I see this a lot, anecdotally). The Either monad (or Rust’s Result, which I’m more familiar with) force you to do something with the error explicitly.
Exceptional cases are just as normal a part of a program as any other flow, including the success flows. If you have 20 happy paths and 80 exception paths, and only cover those 20 happy paths, you’ve covered 20% of the cases.
Because the reality is that people don’t document errors (what exceptions can be raised by a method), don’t explicitly handle all the cases (how many times have you returned a 500 in a Flask app from missing an error type in your
except
block/missing an errorhandler), or don’t even think to put a try…except around fallible code (I see this a lot, anecdotally). TheEither
monad (or Rust’sResult
, which I’m more familiar with) force you to do something with the error explicitly.Exceptional cases are just as normal a part of a program as any other flow, including the success flows. If you have 20 happy paths and 80 exception paths, and only cover those 20 happy paths, you’ve covered 20% of the cases.