Troubleshooting — Reading Errors Properly
The error message is the first source of information when something goes
The Concept
The default failure mode, for most people, is:
- See the error.
- Skim.
- Guess at the cause.
- Try a fix.
- Try another fix.
- Try five more.
- Finally read the error.
Step 7 is where most debugging time goes. Cut it out.
Build It
For this conceptual lesson, the work is one short scenario in a Claude Code session to confirm the section landed:
- Open a fresh session in any project folder.
- Apply the idea in the section above to your project in a way that fits.
- Notice what happens when the condition in the section is met, and when it is not.
Pass: you can describe the difference between the two cases in one paragraph.
Habit 1: read the first line and the last line
Errors have a beginning, middle, and end. The middle is often stack frames or context. The first and last lines are usually the actual statement of the problem.
Example shape:
Error: cannot read property 'foo' of undefined
at Object.<anonymous> (/path/to/file.js:42:17)
at Module._compile (...)
...
status: 'failed',
hint: 'check that the user object is loaded before this call'
The first line says what. The last line says what to do.
Read both, slowly, out loud if it helps.
Habit 2: read the path and the line number
Errors usually point at a file and a line. Open that file. Go to that line. Look at the context around it. Most errors are local. Most errors that look global are local at the line in the error.
If the line number is missing, the error message is hiding it. That is itself information: the tool cannot tell where the failure is.
Habit 3: read what the tool said before the error
The tool often prints a header or a status above the actual error. Like:
Running tests...
Failure: 3 tests failed.
[error here]
The line right above the error — and the line right above that — is what the tool was doing when it failed. If you only read the bottom, you miss the prelude.
Habit 4: ask the tool to read the error for you
If the error is from the tool itself (it tried to use a tool and got a failure back), you can ask the tool to interpret it. Paste or quote the error back to it. Say: "what does this tell you?"
The tool can usually restate the error in plainer words, point at the file, and suggest the next step. Use this. The tool is good at the very thing you may be bad at: reading errors carefully.
Learning Objectives
By the end of this lesson you can:
- Read the first and last lines of an error and name what each tells you
- Open the file at the line the error points to and read the context
- Ask the tool to interpret an error you do not understand
- Stop guessing at fixes and start with the error text
The Problem
Something failed. You see a wall of error text. You close it and try a fix. The fix does not work. You try another. An hour later, you are still guessing.
The wall of text was telling you what was wrong. The lesson exists to make that wall of text the first thing you read, not the last.
The reframe
The reframe: Most "the tool is broken" reports are "I did not read the error." Read it. The error tells you what to do next.
If a fix the tool suggested did not work, that is also a report. Did the suggestion match the error's first and last lines? If not, the suggestion was a guess. Try the next habit above, not the next guess.
A worked example
Symptom: tests fail. Tool output looks like a wall of text.
What you do:
- Scroll to the bottom. Read the last line.
- Scroll to the top of the failing test's output. Read the first line.
- Find the file and line in the message.
- Open that file. Look at the line.
- If still unclear, ask the tool: "read this error and tell me what to do next."
Total time: under two minutes, usually.
Total time without the habits: twenty minutes of poking, more likely.
Three practical consequences
1. Slow down on the first error. Speed up on the rest. Errors cluster. One real cause, several symptoms.
2. Errors lie, but only a little. Read them as the tool's best guess about what happened. Re-verify if the fix does not work.
3. The error is data. Save it. Quote it. Search for it. Send it to the tool. Do not retype.
Use It
| Situation | Do this first |
|---|---|
| See an error you do not understand | Read the first and last lines, out loud |
| See a path and line in the error | Open the file at that line, read the context |
| See a long stack trace | Read the first and last lines; ignore the middle for now |
| The tool suggests a fix that did not work | Check whether the suggestion matches the error text; if not, you are guessing |
| You have spent ten minutes on the same error | Stop. Read the error. If still stuck, paste it back to the tool |
Exercises
- Read an error properly without guessing. In any folder, run a known failing test or command. If you do not have one, write a small test that fails on purpose. Read the entire error block. Slowly. Pass: you can name the first line, the last line, the file and line, and the suggested action if any — without looking back at the error.
- Find the local context. Take an error that points to a file and line. Open the file. Read the five lines around the line the error named. Pass: the error makes sense in the context. Either you can name a fix, or you can name what you would ask the tool about.
- Send the error back to the tool. Find a real error from a real session. Paste it back to the tool and ask: "what does this tell you?" Pass: the tool's response names a file, a line, and a probable cause. The response is grounded in the error text, not a guess.
Key Terms
| What people say | What it actually means |
|---|---|
| "The tool is broken." | Almost never. The tool produced an error and you did not read it. The misconception is that errors are noise. They are information. |
| "Stack trace." | The middle of an error. The first and last lines are the actual statement. |
| "Logs." | The same rules as errors: first line, last line, file path, line number. Same habits. |
| "What to do next." | Usually stated in the last line of an error, or two lines above. Read there. |
What this lesson does not cover
We did not cover specific error formats for specific tools. We did not cover how to attach debuggers or step through code. We did not cover how to read stack traces in languages we did not mention.
This lesson was about the four habits and the one reframe: read the error.
Check yourself
4 questions. Answer before you reveal — recognising the right option is not the same as being able to produce it.
-
You see a wall of error text, most of it stack frames. What do you read first?
Show answer
B. The first and last lines — one states the problem, the other usually suggests the next step
The first line says what went wrong and the last usually says what to do, so those two carry the most signal. Option A is tempting because the frames look dense and technical, but the middle is mostly context. Option C is about your last attempt, not this failure. Option D opens a file the error has not pointed you at yet.
-
Claude Code suggested a fix. It did not work. What does that tell you?
Show answer
B. Check whether the suggestion actually matched the error's first and last lines; if it did not, it was a guess
A failed suggestion is a report about whether the fix was grounded in the error text — if it does not match the first and last lines, it was a guess. Option A is the tempting "tool is broken" move the reframe targets. Option C blames the error instead of checking the fix against it. Option D addresses nothing.
-
An error reads
at Object.<anonymous> (/app/src/user.js:42:17). What is your next move?Show answer
B. Open
/app/src/user.jsat line 42 and read the lines around itMost errors are local, so the file-and-line in the message is where to look and the surrounding lines give the context. Option A searches broadly for a name the error already narrowed down. Option C hopes a real failure is flaky. Option D discards the most specific clue the error gave you.
-
An error from a tool call makes no sense to you. What is the best move?
Show answer
B. Paste or quote the actual error text and ask Claude Code what it tells you
The error is data — hand the real text to the tool, which is good at restating it in plainer words and pointing at the line. Option A is tempting, but a retyped error drifts and loses the detail that mattered. Option C is the guessing loop the lesson exists to cut. Option D throws away the context you need to understand the failure.