Chapter 17: Exceptions

Learning Objectives

Upon completing all the content in this chapter, you should be able to do the following:

  1. Effectively throw and catch exceptions to improve user experience and make debugging easier
  2. Explain what an exception is and why exceptions are used
  3. Write a program using a try/catch block
  4. Catch exceptions only when something meaningful can be done
  5. Throw exceptions with clear, descriptive messages
  6. Throw exceptions only when the program can not be properly executed in the given state
  7. Give at least three examples of standard exceptions
  8. Explain how a finally block works and when one should be used
  9. Create negative tests to verify that code throws an exception when necessary

Key Terminology

Here is a list of key terms for this chapter broken down by the page the term first appears on. You should make note of these terms and their definitions.

Introduction

  1. exception
  2. stacktrace
  3. Error
  4. SyntaxError
  5. ReferenceError
  6. TypeError

Throw

  1. throws

Exceptions and Control Flow

  1. control flow
  2. try
  3. catch
  4. finally