Core · Module 8 · Lesson 4 of 5
Project: Failing Library Operations Cleanly
Build a LibraryError hierarchy, validate a checkout before mutating, and commit with noexcept swaps so failures leave no residue.
Pro — members onlyAbout 12 minutes
By the end you can
- Design a LibraryError hierarchy rooted in runtime_error
- Validate checkout preconditions before mutating shared state
- Commit loans with strong safety and centralized handling
01 · A question first
The desk tries to loan a missing book to an expired member with fines outstanding. Three checks fail at once, the log shows one vague line, and the shelf count is already decremented. Which error should the patron see, and how do you unwind the half-applied loan?
Make a guess before you read on.
02 · The idea
Members only
Unlock the full lesson
This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.
What's inside
- Why checkout concentrates every hazard
- How a small hierarchy names each failure
- Why staging makes failure residue impossible
- What it costs and what to enforce
- How to log a failure with context
- Complete solution
- Where it is used
03 · Practice
Asked in interviews
Something wrong with this lesson? Report a problem