Modern C++ Error Handling
Talkat CppCon 2024 · on Wednesday, 2024-09-18· at 16:45· Adams A, 6700 North Gaylord Rockies Boulevard·
summary
Covers concrete choices not high-level promises: C++17 std::optional and C++23 std::expected with the Monadic Operations (transform and_then transform_error or_else) are shown in real code and compared to exceptions, boolean/error‑code returns, out‑params and globals. Examples include composing error returns with lambdas, a checked/unchecked policy (compile‑time template switch) and a correct‑by‑construction month type, plus a substitutable throwing violation handler for contracts and the checked/unchecked policy to defer who decides how to handle errors.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 1:47Why modern C++ error handling matters
- 3:56Disappointments vs logic errors
- 5:18Traditional error handling techniques
- 11:00Limitations of exceptions
- 12:46C++17 std::optional
- 13:52C++23 std::expected benefits
- 16:00Composition challenges with std::expected
- 18:52Immediately invoked lambdas
- 20:15Monadic operations in C++23
- 28:55Part two transition
- 29:16Invalid inputs with contracts
- 32:32Checked vs unchecked functions
- 34:43Policy-based error handling
- 37:13Correct by construction
- 40:00Contracts in C++
- 40:43C++26 contracts proposal
- 46:20Liskov rule and testing contracts
- 51:22Summary
- 52:46Q&A
related talks
17mA closer look into error handling techniques
52mHigher Order Functions for ordinary developers
27mUsing Monads for Elegant Error Handling
44mInitiatory Journey from Exceptions to Composable Error Types
01h 05mBetter Code: Contracts in C++
35mHandling Exceptional Conditions with Grace and Elegance
27mModeling errors in Now CLI
01h 11mPragmatic Simplicity - Actionable Guidelines To Tame Cpp Complexity
