Logo
READLEARNKNOWCONNECT
Back to posts
find-the-bug-in-3-lines

Find the Bug in 3 Lines

ChriseApril 08, 2026 at 10 PM WAT

How to Read a Stack Trace (Without Your Eyes Glazing Over)

That wall of text is useful. Here's how to read a stack trace and find the actual bug in a few seconds, in any language.

You run your code. Red text floods the terminal. It looks like a lot, but most of it isn't for you. A stack trace is just a log of where the program was and what it was doing when it stopped. Your job is to find the part that matters.

Where to Look First

Scan the stack trace for these three things in order.

  • The error message at the bottom. It tells you what kind of error happened. KeyError in Python, TypeError in JavaScript, NullPointerException in Java. That's your first clue.
  • The file name. Look for the name of your script or a file you recognize. Ignore anything from language internals, standard libraries, or third party packages.
  • The line number. Next to the file name, you'll see a number. That's exactly where the program crashed.

Once you have those three things, you know where to open your editor and what kind of problem to look for.

A Real Example

In Python, you might see this.

code
File "/home/you/project/app.py", line 12, in get_user
    return user_data[user_id]
KeyError: 'delta'

In JavaScript, it looks different but works the same way.

code
at getValue (/home/you/project/app.js:12:15)
    at processUser (/home/you/project/app.js:8:10)
TypeError: Cannot read property 'state' of undefined

Both tell you the file name, the line number, and the error. The Python one says KeyError: 'delta' (a dictionary key is missing). The JavaScript one says TypeError (something is undefined when it shouldn't be). Same structure. Different syntax.

What to Ignore

Stack traces include many lines but most are noise. Ignore lines from language internals or third party packages unless you suspect the bug is actually there. Focus only on lines pointing to files you wrote. The rest is just the program's path to the crash, not your problem.

Tags

#beginner-guides#debugging#programming#stack-trace#tutorial

Join the Discussion

Enjoyed this? Ask questions, share your take (hot, lukewarm, or undecided), or follow the thread with people in real time. The community’s open, join us.