Reading Errors

Red text isn’t anger. It’s directions.

▶ the lesson · narrated sketch video · tap for sound

the intro

Error messages are the most under-read documentation in software. Stack traces read bottom-up: the bottom is where your code entered, the top is where it exploded. The message usually states exactly what went wrong, in which file, at which line.

fun fact ✦

“Undefined is not a function” has saved fewer careers than reading the message would have.

the docs

the deep dive

the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid

An error message is not the machine yelling — it is a note left behind by the last developer who hit this exact wall. Runtime authors spend real effort writing "Cannot read properties of undefined (reading items)" so you do not have to guess. Your whole job at the red screen is translation: what did it expect, what did it get, and where did those two diverge?

what did it expect, what did it get

where it threwlibrary framesyour function
the top frame is the crime scene; walk down to the file with your name on it

key terms

stack trace

The list of function calls in flight when the error fired, crash site first.

at handleClick (app.js:42)

error message

The what: one sentence from the runtime naming the exact failure and the offending value.

Cannot read 'name' of undefined

frame

One line of the trace: function, file, line number. Yours or the library's — that is the whole triage.

at render (cart.tsx:17)

exit code

For command-line tools: 0 means success, anything else is a failure you can look up.

exit code 1 = generic failure

how it works

  1. 1
    Read the message, really

    Out loud if you have to. Most messages name the exact type, value, and file — skimming wastes the best clue you have.

  2. 2
    Find your frame

    Scan the trace for a file you wrote. That line is where your code handed off to the failing path.

  3. 3
    Name expected versus got

    The error wanted a function and got undefined. The sentence "expected X, got Y" is usually the bug, stated.

  4. 4
    Search the exact text

    Copy the message in quotes, add your framework and version. Someone hit this before you, almost certainly.

the code, explained

read it like a detective: the what, then the where, then whose fault

1TypeError: Cannot read properties
the what: tried .items on undefined
2of undefined (reading 'items')
3 at getCart (cart.ts:31)
your frame — open this line first
4 at checkout (store.ts:88)
5 at Server.handler (node:internals)
framework noise — skim, do not chase

side by side

caught at compile time

  • fails before anything ships
  • types, syntax, missing imports
  • cheapest place to be wrong
VS

thrown at runtime

  • fires only on the exact bad input
  • tests, logs or users find it
  • users may see it before you
🪤 gotcha

Fix the first error, then re-run. One broken line can manufacture a dozen innocent-looking errors below it, and chasing error number seven wastes an hour on a symptom of a symptom.

quick answers

The trace is 200 lines, all framework code. Now what?

Search it for your own folders first. If none appear, the bug is likely in how you call the library: check the arguments and versions, then search the message with the framework name attached.

What about failures with no stack trace at all?

Something always observed it: exit codes, log files, the network tab, a failed request payload. Read whatever the machine did leave behind — silence is rarer than it feels.

Should I always Google the error?

After reading it, not instead of reading it. The message tells you which of ten search results actually matches your code; without it you are just pasting.

quick hits about Reading Errors

short answers · interviews, tips, trivia & hidden gems

🎤 interview

Read stack traces bottom-upwatch ↗

📚 tutorial

Stack trace anatomywatch ↗

🔧 useful

Search it — in quoteswatch ↗

💎 deep

Errors are a map, not a verdictwatch ↗