Skip to content

Commit

Permalink
Update async_and_await.md
Browse files Browse the repository at this point in the history
Rephrase the try catch paragraph and add a link to the try catch
docs ought to make a clearer introduction.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
  • Loading branch information
c8in4 committed Sep 27, 2024
1 parent e26b6b9 commit 3a71ebd
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ asyncFunctionCall().catch(err => {
});
```

But there is another way: the mighty `try/catch` block! If you want to handle the error directly inside the `async` function, you can use `try/catch` just like you would inside synchronous code.
But there is another way: the mighty [try/catch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) block! If you want to handle the error directly inside the async function, you can use `try/catch` with `async/await` syntax. If JavaScript throws an error in the `try` block, the `catch` block code will run instead (this can also be used for synchronous code).

```javascript
async function getPersonsInfo(name) {
Expand Down

0 comments on commit 3a71ebd

Please sign in to comment.