~/talk

C++ Error Handling

Talkat ACCU 2025 · 2025-04-01..04-04· [c-and-cpp]
name:Roger Orr
links:none on file
slides:none on file

Examines a simple C++ generator class (configure + operator()) and then actually adds and compares real error strategies: logging to cerr (cheap but fragile), throwing std::runtime_error and small custom exception types (keeps happy path unchanged but forces unwind/RAII and changes control flow), returning bool or enum/status (easy but frequently ignored), returning string or status object, out-parameter/last_error, std::optional vs std::expected (optional loses diagnostics; expected handles void too), and mapping exceptions into return values; concludes error handling multiplies code and choices, so examples omit it.

AI-written summary · about

  1. 0:00Error handling in C++
  2. 1:33Why error handling is omitted
  3. 5:47Context-dependent error handling
  4. 10:43Error reporting five Ws
  5. 17:29Who needs error messages
  6. 21:07Support teams and error design
  7. 25:58Error message information
  8. 33:37Where to send logs
  9. 38:13Simple C++ example
  10. 42:08Adding comments and logging
  11. 49:13Reporting errors with exceptions
  12. 53:24Exceptions and control flow
  13. 1:01:12Returning error statuses
  14. 1:14:25Handling errors in non-void
  15. 1:22:15Using expected for errors
  16. 1:26:58Exceptions vs return codes
  17. 1:28:23Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.