this post was submitted on 18 Aug 2023
38 points (100.0% liked)

Programming

423 readers
2 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] TehPers 9 points 1 year ago

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.