On this page
Error-Handling Philosophies
Prev: Modularity, Cohesion & Coupling | Up: software_design | Next: Testing & Maintainability
Rel: Type Systems, Python Error Handling, JS Error Handling
Ref: Wikipedia — Exception Handling
Tags: #public #prog #programming #design #errors
Contents
Three Primary Error Models
| Model | Examples | Mechanism | Trade-off |
|---|---|---|---|
| Return / Error Codes | C (errno), Go (val, err) |
Explicit return value checked by caller | Visible control flow; verbose if ignored |
Algebraic Result / Option |
Rust, Haskell, Swift | Compiler-enforced sum types (Ok/Err, Some/None) |
Eliminates null crashes & unhandled errors |
| Exceptions | Python, Java, JavaScript | Unwinds call stack to nearest catch/except |
Clean happy path; hidden exit paths |
Bugs vs. Expected Failures
- Programmer bugs (violated internal invariants, out-of-bounds index): fail fast with assertions/panics so corruption never spreads silently.
- Expected runtime failures (network timeout, missing file, bad user input): handle explicitly at the boundary, preserve root-cause context, and never swallow errors silently.
Linked from
- tuts/c/compilation_and_internals/error_handling_and_cleanup
- tuts/programming/data_and_types/type_systems
- tuts/programming/software_design
- tuts/programming/software_design/error_handling_philosophies
- tuts/programming/software_design/modularity_cohesion_and_coupling
- tuts/programming/software_design/testing_and_maintainability
- tuts/rust/ownership_and_internals/enums_pattern_matching_and_errors
- tuts/typescript/tutorials/discriminated_unions_and_state_machines
Related notes
- tuts/programming/software_design Linked here; links to this page; shared tags: #design, #prog, #programming
- tuts/programming/software_design/modularity_cohesion_and_coupling Linked here; links to this page; shared tags: #design, #prog, #programming
- tuts/programming/software_design/testing_and_maintainability Linked here; links to this page; shared tags: #design, #prog, #programming
- tuts/programming/data_and_types/type_systems Linked here; links to this page; shared tags: #prog, #programming
- tuts/c/compilation_and_internals/error_handling_and_cleanup links to this page; shared tags: #errors, #prog
- tuts/rust/ownership_and_internals/enums_pattern_matching_and_errors links to this page; shared tags: #errors, #prog
- tuts/javascript/tutorials/modules_and_error_handling Linked here; shared tags: #errors
- tuts/python3/tutorials/intermediate_python_and_software_engineering/error_handling_and_context_managers Linked here
- tuts/typescript/tutorials/discriminated_unions_and_state_machines links to this page
- tuts/programming shared tags: #prog, #programming