What happens when something fails.
EXCEPTIONS
Errors thrown and caught elsewhere.
What they provide: separating error handling from the main path.
What they cost: it is not visible from a function signature what may fail.
RETURN VALUES
Errors returned alongside results, checked by the caller.
What they provide: explicitness. Every failure is visible.
What they cost: verbosity, and the temptation to ignore them.
RESULT TYPES
A value representing either success or failure, which must be handled to obtain the result.
What they provide: explicitness enforced by the compiler.
WHAT ALL APPROACHES SHARE
Errors ignored produce worse outcomes later.
WHAT TO DO IN ANY LANGUAGE
Handle failure where you can do something about it Propagate where you cannot Never silently discard an error
WHAT SILENT DISCARDING LOOKS LIKE
Catching everything and doing nothing.
WHY IT IS SO DAMAGING
The program continues in an unknown state, and the cause is invisible.
WHAT TO ALWAYS LOG
Enough to identify what failed and where.
WHAT TO NEVER EXPOSE TO USERS
Internal error detail.