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 unless it is handled.
- How to create an error using the
- How to throw an error object using the
- How to use the
try...catchstatement to handle thrown errors.
- Evaluating code in a
tryblock to anticipate errors.
- Catching the error in a
catchblock to allow our program to continue running.
- Why the
try...catchstatement would be useful in a program.
Now you have the ability to create code that doesn’t break when an error is thrown!
If you want to challenge yourself:
- Force different built-in error object to be thrown in a
try...catchstatement and see when the messages are different.
- Test out what different data types you can throw.
try...catchfor a function that accepts user input to allow errors to be thrown but your program to continue running.