Your Error Handling Code Has Never Actually Run

Open your codebase and search for catch, .catch(, or except. There's a good chance a meaningful fraction of those blocks have never executed outside a unit test with a mocked rejection — not because they're unreachable, but because the real API they're guarding against has simply never failed while someone was watching.
That's a problem, because error-handling code that's never run in anger is a guess, not a tested behavior. It might swallow the error silently. It might throw a worse, unhandled error trying to read a field off a response that doesn't exist. It might retry in a tight loop with no backoff and make an outage worse. You don't find out which until it happens for real, at the worst possible time, in front of a customer.
Why "just wait for a real outage" doesn't work as a test strategy
Real API failures are:
- Rare. A dependency with 99.9% uptime fails, on average, for under nine hours a year — spread unpredictably, not conveniently scheduled for your test cycle.
- Inconsistent. A timeout looks different from a 500, which looks different from a malformed response, which looks different from a connection reset. Your code might handle one and choke on another.
- Badly timed. The one moment you'd actually want to observe your fallback UI kick in is also the one moment a real user is staring at a broken screen.
Netflix's engineering team gave this problem a name over a decade ago with Chaos Monkey — a tool that randomly kills production instances specifically so that failure becomes a normal, expected, tested event instead of a rare catastrophe. The idea generalized into "chaos engineering": deliberately injecting failure into a system you control, so you learn its actual behavior under stress instead of assuming it.
What this looks like for a team that isn't Netflix
You don't need a distributed systems team or a service mesh to apply the same idea to something much smaller: the specific API calls your frontend or backend makes to a specific dependency.
The practical version of this is: take an API you depend on, and make it fail on purpose, at a rate you control, while you watch what your own code does about it. Concretely, that means being able to answer:
- If this endpoint returns a
500, does the UI show a real error message, or a blank screen? - If it returns
429, does your client actually back off, or does it hammer the endpoint harder? - If it hangs for 8 seconds instead of responding in 200ms, does the user see a spinner that eventually times out gracefully, or does the whole page lock up?
- If it fails 1 time in 5 — not always, not never — does your retry logic actually recover, or does it also fail 1 time in 5?
That last one matters more than the always-fails case. A route that returns an error 100% of the time is easy to notice and easy to test against, but it's not what a real flaky dependency looks like. Real flakiness is intermittent, which is exactly the condition under which retry logic either proves itself or quietly doesn't work.
Building this into a normal test cycle
The practical setup is: point your app at a mock of the dependency instead of the real thing, configure that mock to fail at a rate you choose, and run your actual client code against it — not a hand-written unit test double, but the real network call, real serialization, real error-handling path, all the way through.
In MockBase this is chaos injection: set an error rate on a route (say, 20%) and a status code to fail with, and roughly 1 in 5 real requests to that route comes back as that error while the rest behave normally — independent per request, not a predictable pattern, which is what makes it a decent stand-in for a genuinely flaky upstream rather than a scripted failure. Pair it with a configured delay on the same or a different route and you can test slow-and-occasionally-broken, which is closer to what most real incidents actually look like than a clean, evenly-spaced failure would be.
The goal isn't to prove your app never fails — it will, eventually, against something. The goal is to make sure that when it does, what a user sees is "hang on, retrying" instead of a stack trace, and what you see in your monitoring is a clear signal instead of a mystery. That only happens if the failure path has actually run before it's live.
Xerat02
Building MockBase.
More from the blog

Designing Error Responses People Can Actually Debug
"Something went wrong" tells a developer nothing they didn't already know. A good error response answers what happened, why, and what they can do about it.

Nobody Tests the Sad Path
Most QA time goes to confirming a feature works when everything goes right. The error states — the ones a real user is far more likely to actually see during an incident — usually get a glance, if that.