3 Docs Feeder 4 The Guide ~9 min

Error Handling in Code: So Nothing Fails Silently

When it breaks, you should be the one who finds out. Not a client in an angry email a week later.

Error handling for vibecoders: a clear message for humans, a full log for you, smart request retries, and a ready-made prompt so your agent stops hiding failures.

ECC skills in this lesson: error-handling

What error handling actually is, in plain words

Picture a pipe bursting in your home. Two scenarios follow.

First: somewhere under the floor, water is quietly dripping. No sound, no signal. You live happily for a month — and then you find rotted floorboards and a flood in the apartment below. The disaster happened. You found out last.

Second: the pipe springs a leak — and instantly the sensor blares, the valve shuts off, a notification hits your phone. Annoying? You bet. But you fix everything in an hour, while the problem is still the size of a puddle.

That’s exactly what error handling is. A program always breaks somewhere — it’s as inevitable as rain. The only question is: do you find out immediately and gently, or later and as a catastrophe?

On the left, a pipe quietly dripping under the floor; on the right, a blaring leak sensor with a phone notification
On the left, the error stays silent and piles up. On the right, it screams right away. Pick the right side.

Why error handling matters for a vibecoder

You’re a vibecoder. The agent writes the code for you. But you’re the one who decides how the app behaves when something goes wrong — and something goes wrong constantly: the internet hiccups, a person types in nonsense, somebody else’s service lies down for a nap.

Don’t give the agent rules about errors, and by default it’ll pick the most dangerous option. It’ll hide them. Everything looks fine on the outside, while inside it’s quietly dripping.

  • The user sees a blank screen or an eternal spinner — and leaves without a word. They won’t even write to you.
  • You have no idea what broke: the error left no trace anywhere.
  • One tiny failure takes down the whole app — when it could have stayed a local nothing.

The difference between “my site glitches sometimes, no clue why” and “I see every problem in the logs and fix it in a minute” — that’s the culture of error handling. The good news: the rules are simple. Wire them into your prompt once, and forget about it.

Five rules of good error handling

The error-handling skill has five iron principles. Let’s break each one down in plain terms.

1. Fail fast and loud

The most harmful thing you can do is swallow an error . If it breaks, it should surface right where it happened. Not get buried deeper “so nobody panics.”

Sounds obvious. But this is exactly where beginners (and lazy agents) trip up most often: they add a catch block — and leave it empty. It’s like slapping electrical tape over a blinking “check engine” light. The light isn’t blinking, so everything’s fine, right? Sure, sure.

2. One message for the human, another for you

The same error needs two different texts:

  • For the human — short and polite: “Something went wrong, try again later.” No technical details, no scary words, no chunks of code on screen.
  • For your log — the whole story: what exactly broke, where, and with what data. This is your leak sensor.
One error splits in two: to the left a polite note for the user, to the right a detailed report for the developer
One disaster, two messages. Calm for the client, the truth for you.

3. An error should have a name, not just text

A bad error is a bare string "something broke". It tells you absolutely nothing.

A good error is typed : it has a code and a clear name. Look:

  • NotFound — the thing you asked for isn’t there.
  • Unauthorized — you need to sign in.
  • ValidationError — the person typed in something wrong.
  • RateLimited — too many requests in a row, time to ease off.

When errors are named, the app knows exactly what to show the human and what response to return. “Not found” is nothing like “no access” or “our server lay down for a rest.”

4. Retry requests smartly, not by ramming your head into the wall

Sometimes an error is temporary: the internet hiccupped, a service froze for a second. That’s where a retry with a growing pause makes sense: try once more; if it doesn’t work, wait a bit longer, and so on a few times.

But you can’t retry just anything:

What you can retry
  • The network hiccupped, a connection timeout — it might fix itself in a second.
  • Someone else's server replied “I'm temporarily overloaded” — wait and retry.
  • Retry with a growing pause, not back-to-back — give the system room to breathe.
What's pointless (and harmful) to retry
  • The person entered the wrong password — retrying won't help, the password won't fix itself.
  • “Not found” — what isn't there isn't there, ask a hundred times if you like.
  • Endless retries with no limit — you'll finish off someone else's server and hang yourself.

5. An error is part of the contract with whoever uses your code

If your app can return a “no access” or “too many requests” error, let it do so in one clear format every time. Then the frontend, you yourself, and any future agent always know what to expect. Chaotic, inconsistent-looking errors are the second-biggest source of pain, right after silent ones.

A real-life example: the form that silently lost submissions

You built a contact form on your site with the agent. Poked at it — works. Shipped it. A week later you notice: zero submissions. Even though the counter insists dozens of people opened the form.

What actually happened:

  1. The email-sending service ran out of quota — it started returning an error.
  2. By default, the agent wrapped the send in a catch block and left it empty.
  3. So the human saw a cheerful “Thanks, your message was sent!” — while the email went nowhere. It dripped quietly under the floor for a whole week.

How do you protect yourself from the start? Just give the agent the rules. Here’s a ready-made prompt:

Prompt — copy it and give it a try

Whenever you write any code that could break (network requests, database work, sending emails, user input), follow these rules:

  1. Never leave an empty error-handling block. Every such block must either handle the failure properly, pass it along, or write it to a log.

  2. For every error, produce two messages. For the user — short and polite, with no technical details. For the log — full information: what broke, where, and with what data.

  3. Don’t show the user success until the action has actually completed. If the email didn’t send, say honestly that it failed and offer to retry.

  4. Use clear typed errors with codes: not found, no access, invalid input, too many requests, internal error.

  5. Retry a request automatically only if it could have failed by chance (network, timeout). Use a retry with a growing pause and cap the number of attempts at three. Don’t retry input or access errors.

At the end, show me a list of the places where the code could fail, and how you handle the error in each one.

Healthy vs. sick error handling: a comparison

Healthy error handling
  • Every failure surfaces somewhere: in a log, on screen, or higher up in the code.
  • The human sees a clear message, not a stack trace filling half the screen.
  • The logs hold the whole technical truth — you fix based on facts, not tea-leaf guessing.
  • Only temporary failures get retried, with a pause and an attempt limit.
Sick error handling
  • Empty “caught it and staying quiet” blocks — errors vanish without a trace.
  • The human gets dumped a chunk of code or a blank screen.
  • One tiny error takes down the entire app.
  • Passwords or keys end up in the log — and then the log leaks somewhere.

Checklist: is your app silent about its errors

Before you roll anything out to people, run it through this checklist:

  1. What will the human see if this breaks? If the answer is “blank screen” or “no idea” — that’s bad.
  2. Where will I see that this broke? If nowhere — add a log.
  3. Are there any empty error-handling blocks? Ask the agent to show you every catch and what happens inside it.
  4. Am I showing success too early? “Sent” should appear only after it’s actually sent.
  5. Did any secrets leak into the logs? Passwords, tokens, and keys have no place in a log.
Meme: a robot-app smiles calmly while the room around it burns with uncaught errors
A genre classic: calm on the outside, an inferno inside.

Common beginner mistakes in error handling

  • Leaving the catch block empty. The most dangerous habit there is. The error disappears, the problem grows in the dark.
  • Showing the human technical text. A stack trace on screen scares ordinary people and helps attackers. Give them a polite message; keep the log for yourself.
  • Lying about success. “Done!” before the action actually happened is a direct route to lost submissions and orders.
  • Retrying things a retry can’t fix. A wrong password or a “not found” a hundred times in a row is wasted effort and a load on the server.
  • Endless retries with no limit. You’ll finish off someone else’s service and hang your own app along with it.
  • Logging secrets. It’s tempting to log “the whole request,” but passwords and keys often fly in with it. Scrub out anything sensitive.

TL;DR - если коротко

  • A silent error is the worst kind. A failure should scream right where it happened, not get swept under the rug.
  • Two texts per error: a polite “oops, try again later” for the human, the full story for you in the log.
  • An empty catch block is a time bomb. Every one of them has to handle, rethrow, or log.
  • A name instead of a faceless string. Typed errors with a code: NotFound, Unauthorized, RateLimited.
  • Retry with your head, not your forehead. Only what fixes itself, with a growing pause and a limit — not a line marching into a wall.
  • Run the checklist before you ship. What the human sees, where you see it, no empty blocks, no lying about success.

Search Wiki

Press Esc to close

Enter a search term to query all course pages and lessons.