how to read an error message

May 26, 20213 min read

I’m mentoring two new programmers, and remembering what it’s like to learn programming. You follow a tutorial, you write some code, you run it just like they tell you to…and you’re hit with a long error message full of words you don’t understand like Manager object and module.

It’s too daunting to read, so you copy the message into Google, then copy the first response from Stack Overflow. The original error message goes away but now there’s a new error message in its place. Did you solve the original error, or did you just mess things up even further? It’s unclear.

Here’s my advice for new programmers on how to read error messages:

  1. Go slower. When you get an error message, read the error message. Then try to understand the message, which might involve re-reading it 5 more times.
  2. If you have a super long error message, you can skim or skip the middle part. The last or second-to-last line of the error message usually has a one sentence description of the error. Early in the error message, you might see a traceback that points you to the exact line in your code that’s failing — that’s helpful too, look for that.
  3. Do not just copy and paste the entire error into Google by default. The problem with copy-pasting an error into Google is that you won’t learn anything. If you want to get good at programming, you need to learn how to parse error messages. If you rely on blind copy-pasta forever, you’ll always be just as lost as you are right now. Instead, make a guess as to why the error occurred. Google is still your friend, but instead of googling the exact error message, make searches based on your understanding of the error.
  1. It’s totally normal to run into 10 error messages in a row. That’s just programming — it’s frustrating, but it’s why programmers are paid so well. Even when you have more experience, you’ll run into this. Regularly! So no need to get anxious if you run into one error message after another.
  2. You MUST use a notebook while you code. If you follow an error rabbit hole for 10 errors, you’ll probably forget what you were trying to do in the first place, when you finally resolve them all. So it’s helpful to write down what you’re working on, so you can remind yourself of the big picture when you emerge from Error Hell.

In short:

  1. Read the error message. Actually. Read it.
  2. Okay, you don’t have to read the whole thing if it’s long. But read the beginning and the end, carefully, until it starts to make sense.
  3. Use your newfound understanding of the error to write a more useful search query than simply copy and pasting the error text.
  4. You’re gonna see a lot of error messages, kid. Don’t stress.
  5. Use a notebook or you’ll get lost.