Errors and Error Handling

Learn how to address errors in this course all about JavaScript errors!

Start[missing "en.views.course_landing_page.javascript-errors-debugging.course_illustration" translation]
Chevron Left Icon
Debugging JavaScript Code
Lesson 1 of 2
Chevron Right Icon
  1. 1

    Any programmer will tell you that it is incredibly common to be making great progress working through a coding problem when all of a sudden an error like this gets thrown at you: [...] Alternat...

  2. 2

    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 ...

  3. 3

    Now that we know what information we can get from an error stack trace, let's take a look at an example. [...] Using this stack trace, let's answer three questions you should ask yourself every...

  4. 4

    Now that you can identify the type of error from an error stack trace, you might be wondering what the different types of errors mean. Here are three common error types: *SyntaxError: This er...

  5. 5

    Here's a process for efficiently working through your code's errors one by one: 1. Run your code. Using the first error's stack trace, identify the error's type, description, and location. 2. Go t...

  6. 6

    Errors thrown by the computer are really useful because they identify the bug type and location for you right away. However, even if your code runs error-free, it is not necessarily bug-free. You ...

  7. 7

    Let's synthesize our workflow from the previous exercise into a reusable set of debugging steps. 1. Go to the beginning of the malfunctioning code. Print out all starting variables, existing value...

  8. 8

    Sometimes once you've tracked down a bug, you might still be confused on how to fix it! Whenever you want to know more about how JavaScript works and what it can do, the best place to go is **docum...

  9. 9

    At this point, you might be thinking to yourself, documentation is good and all, but there's no way it will solve all of my issues! And we totally agree. All programming languages have difficult pr...

  10. 10

    You just learned a lot of techniques for helping you get unstuck in all debugging situations. Congratulations! Let's synthesize everything you learned into one debugging process. 1. **Is your code...

  1. 1

    There are two categories of programming mistakes: those that don't prevent our code from running and those that do. Sometimes, we've written code that successfully returns a value but a different...

  2. 2

    Errors contain useful messages that that tell us why our program isn't working or why the error was thrown. When an error is thrown, our program stops running and the console displays red text of...

  3. 3

    JavaScript errors are objects that have a name and message property. Previously, we've seen how built-in errors alert us about common mistakes in our code. But, what if we need an error message tha...

  4. 4

    Creating an error doesn't cause our program to stop — remember, an error must be thrown for it to halt the program. To throw an error in JavaScript, we use the [...] keyword like so: [...

  5. 5

    Up to this point, thrown errors have caused our program to stop running. But, we have the ability anticipate and handle these errors by writing code to address the error and allow our program to...

  6. 6

    In the previous exercise we caught an error that we threw, but we can also use a [...] statement to handle built-in errors that are thrown by the JavaScript engine that is reading and evaluati...

  7. 7

    Great job with handling errors! In this lesson we went over: How mistakes in programming leads to errors. Why errors are useful for developers. * Errors will prevent a program from executing u...

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo

Errors and Error Handling

Start[missing "en.views.course_landing_page.javascript-errors-debugging.course_illustration" translation]