Error Handling
Sometimes code fails. Network requests fail, data is malformed. Try/catch prevents these errors from crashing your app.
Try / Catch
Wrap risky code in try. If it throws an error, the catch block runs.
Throwing Errors
You can create your own errors if invalid data is provided to a function.
Practice
Challenge 1: Write a function that parses JSON string, wrap JSON.parse in try/catch to handle bad JSON gracefully.