wiki/content/20201111095100-catching_promise_errors.md

18 lines
368 B
Markdown
Raw Permalink Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-30 17:34:11 +00:00
date: 2020-11-11
2024-05-06 20:40:05 +00:00
id: af9d9cf2-a888-4e8e-8156-4c4a664450f1
title: Catching Promise Errors
---
# Syntax
``` javascript
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));
```