4 ms·
Would you mind explaining what the benefits of either of those libraries is over normal exception handling? The examples at the top of the Result readme seem al
by drcongo 2y ago
Would you mind explaining what the benefits of either of those libraries is over normal exception handling? The examples at the top of the Result readme seem almost exactly as verbose as each other. I kinda like the idea of a Result object, but it seems like a lot of library imports for no gain so I'm sure I'm missing something.
- benrutter 2y agoNot OP, but as someone who likes this style of exception handling, I really appreciate that it offloads everything to the type system. With normal exceptions, I have to use my meat brain to figure out if I've handled all the exceptions that might come up, whereas mypy can just tell me if I've handled the result object correctly That said, I don't use either library since, in my experience, you need them to be used all the way down the stack to actually get the benefit.
- drcongo 2y agoAhhh, I get it now, thank you!
- BerislavLopac 2y ago> I have to use my meat brain to figure out if I've handled all the exceptions that might come up The point of exceptions is exactly that you don't want to handle all that might come up -- you need to handle only those that you actually expect and know how to handle. Everything else is left to bubble up and either be handled by a custom, generic top-level handler, or by the language's default mechanism (in Python's case, dumping a stack trace).