Error handling in C++: as easy as "use exceptions"?
summary
Compares concrete error APIs: plain return codes and enums, out-parameter patterns (like legacy C/Qt index -1), and exceptions including the four exception-safety levels and vector::at throwing; then demonstrates functional alternatives — std::expected (C++23) and boost::expected, std::optional patterns, Rust-style question-mark semantics and continuation chains — and shows experimental pattern matching demos compiled with the Circle toolchain on Godbolt. Emphasizes library-level strong/basic exception safety and trade-offs for embedded systems.
AI-written summary · about
chapters (13)
- 0:00Intro
- 2:29Classification of issues
- 4:34Examples of errors and exceptional situations
- 6:47General approach to handling
- 15:40Exception safety
- 19:25Add context
- 20:38General characteristics
- 22:46std::optional - special case
- 24:58Naive implementation
- 29:43Functional style
- 32:39Pattern matching in C++
- 38:27Pre-conditions example (non-null pointer)
- 42:22Good practices
related talks
01h 03m“What Could Possibly Go Wrong?: A Tale of Expectations and Exceptions”
45mTo Err is Human - Robust Error Handling in C++26
01h 29mC++ Error Handling
01h 02mBack to Basics: Exception Handling and Exception Safety
01h 04mKEYNOTE: De-fragmenting C++: Making exceptions more affordable and usable
57mAnd Then() Some(T) Functional Adventures With C++23 std::optional and std::expected
59mExpect the expected
53mThe Dawn Of A New Error
