Chapter 17: Exceptions
Learning Objectives
Upon completing all the content in this chapter, you should be able to do the following:
- Effectively throw and catch exceptions to improve user experience and make debugging easier
- Explain what an exception is and why exceptions are used
- Write a program using a try/catch block
- Catch exceptions only when something meaningful can be done
- Throw exceptions with clear, descriptive messages
- Throw exceptions only when the program can not be properly executed in the given state
- Give at least three examples of standard exceptions
- Explain how a finally block works and when one should be used
- 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
- exception
- stacktrace
Error
SyntaxError
ReferenceError
TypeError
Throw
- throws
Exceptions and Control Flow
- control flow
try
catch
finally