We’ll start this lesson by taking a closer look at the most straightforward way to know your code isn’t working as expected: errors!
You might recognize errors as the scary red text that appears on your screen when you try to run broken code. A piece of software, called a compiler, is trying to translate your code so that your computer can understand and run it. However, the compiler is coming across a piece of code that it can’t interpret. As a result, it throws an error back to you to let you know that it has to stop and why.
This information is logged as an error stack trace — a printed message containing information about where the error occurred, what type of error was thrown, and a description of the error.
Take a look at the diagram to the right to see where you can find all of this information.
As a new programmer, it’s easy to see an error and be overcome with a sense of dread and self-doubt. However, you’ll soon realize, errors are the best kind of bug you can hope for, since they tell you exactly what went wrong and where.
Instructions
Take a look at the diagram to the right. When you’re ready, move on to the next exercise to read a real error stack trace using this information.