Software → Programming
Error Handling
Techniques for detecting, representing, propagating, and recovering from failures in software.
Error Handling
Error handling is the deliberate design of how software detects failures, communicates them, contains their effects, and either recovers or stops safely. It includes return values, exceptions, result types, retries, fallback behavior, and user-facing error messages.
Design principles
Handle an error at the layer that has enough context to make a meaningful decision. Preserve the original cause, avoid silently swallowing failures, and distinguish expected business outcomes from unexpected defects. Good error handling produces actionable logs without exposing secrets.
Common mistakes
Catching every exception, retrying non-transient failures, returning ambiguous null values, and converting all failures into generic messages make systems harder to operate. Error contracts should be tested alongside successful behavior.