DEV Community

loading...

Discussion on: Error handling - Returning Results

Collapse
swizzard profile image
sam

Results are great when they're supported by a language (e.g. Haskell, Rust, Elm), but I think it's not unreasonable for callers of a given function to assume (non-null) returned values are 'correct' absent additional information.

Also, you're losing all the benefits of any native type hierarchy, so you'd have to hand-craft any system for when you want to handle some Results but not others. You'd similarly have to painstakingly wrap everything that could throw an exception, and pray that whoever comes along after you does the same, lest native exceptions escape.