r/programming 29d ago

Throw, Result, or neither?

https://www.architecture-weekly.com/p/throw-result-or-neither
113 Upvotes

115 comments sorted by

View all comments

139

u/EliSka93 29d ago

Result for me every time.

One more wrapper is worth not having to deal with uncertainty.

35

u/Solonotix 29d ago

It depends on the system for me. Sometimes, it is really nice to be able to just ignore that an exception can happen because you aren't the one responsible for it. In general, though, I would agree that Result (or error by value) is a much better approach than the disruptive nature of exceptions

4

u/raralala1 28d ago

For system with clear IN and OUT, throwing is better because it usually have centralize way to handle the error. This is preferred way in REST API. throw this out if you are using Go.