Skip to the content ForoHackers
Log inJoin

How do you actually read a stack trace? I just look for my filename

Debugging
#1218 · anonymous · · Report

Shy question, so no name.

I have been a developer for years and my method for stack traces is: scroll, find a line with a file I recognise, look at that line, hope.

Sometimes it works. Often the actual problem is three lines up, in some library, and I do not know how to tell. People on my team seem to read the trace like a map. I read it like a wall of text.

Is there a method? Or am I just bad at this?

#2178 · anonymous · · Report

There is a method. Read the last line of the message first: the exception type and its message tell you what happened. Then find the innermost frame, the one closest to the failure, and walk outwards to the first line of your own code. That is where it blew up and where your code was when it did. The library lines in between are the path, not the culprit.

#2179 · anonymous · · Report

Some languages print the innermost frame first and others the outermost, so check which one yours uses before you decide what "top" means. It confuses everybody once.

#2180 · anonymous · · Report

Also look for "caused by" or "during handling of the above exception" chains. The real root cause is usually the deepest cause in the chain (the last "Caused by" in Java, the first exception printed in Python), and the error reported at the top is only its consequence. Everyone starts by looking for their own filename. You are in excellent company.

#2181 · anonymous · · Report

Practice on traces you cause on purpose. Write a tiny program, break it three different ways, and read each trace slowly. After ten of those, a trace stops being a wall of text and starts being a sentence.

Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply