Waiting and Errors for Node

Waiting and Errors for Node: Handling Errors with try, catch and finally, Promises: then, catch and finally, async and await.

Updated

  1. Handling Errors with try, catch and finally (Apprentice): try runs code that might fail, catch takes over when it does and gets an error object with a name and a message, and finally runs either way, so one bad value doesn't stop your whole program.
  2. Promises: then, catch and finally (Journeyman): A promise is a value that arrives later, like the buzzer a pizza shop hands you, and then, catch and finally say what to do when it works, when it fails, and either way.
  3. async and await (Journeyman): async and await let you write code that waits for promises as if it were a recipe, one step under another, with try and catch for the steps that fail.