wiki/content/20201111095100-catching_promise_errors.md

366 B

date id title
20201111 af9d9cf2-a888-4e8e-8156-4c4a664450f1 Catching Promise Errors

Syntax

new Promise((_, reject) => reject(new Error("Fail")))
  .then(value => console.log("Handler 1"))
  .catch(reason => {
    console.log("Caught failure " + reason);
    return "nothing";
  })
  .then(value => console.log("Handler 2", value));