StoicBuilder

HandbookIII the CastraHandling errors

IIIthe Castra, Stay in control

Handling errors

1 min readUpdated 28 November

In plain words

Handling errors means deciding in advance what your app does when something fails: tell the user what happened, record the details, and never fail silently.

Where you see it

Maya presses Save in Quill as her train enters a tunnel. Either the note quietly vanishes, or a message says "Couldn't save. Your note is still here." The second one is error handling.

src/components/NoteEditor.tsxbrowser
const { error } = await supabase.from("notes").insert(note);if (error) { console.error("note save failed", error.message); toast.error("Couldn't save. Your note is still here."); return;}
Check the error, tell the user plainly, and keep the details for debugging.

What goes wrong

  1. Swallowing errors with an empty catch

    The error disappears and so does your only clue, until a user reports a note that never saved.

    try { await saveNote(note); } catch (e) {}
  2. Showing raw errors to users

    A stack trace or database message on screen confuses people and tells strangers about your tables. Show a plain message and log the details.

  3. Ignoring the error Supabase returns

    Supabase doesn't throw when a query fails; it hands back { data, error }. Code that only reads data treats a failed save as success.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Check the result of every database call and fetch, show the user a short plain message that says what to do next, and log the full details where I can find them. Remove empty catch blocks, and never show stack traces or database messages to users.

Quick check

Sign in to earn +10 XP for it

Quill's Save button seems to work, but some notes are missing later and no errors appear anywhere. A likely cause?

Got a prompt that touches handling errors?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.