Skip to content

Commit

Permalink
Docs: Adds an example with try/catch. (#9672)
Browse files Browse the repository at this point in the history
* Docs: Adds an example with try/catch.

Clarifies with an example that `return await` inside an error handler is allowed by this rule.

* Update no-return-await.md
  • Loading branch information
q42jaap authored and ilyavolodin committed Dec 1, 2017
1 parent 58216b6 commit cdb1488
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/rules/no-return-await.md
Expand Up @@ -30,8 +30,16 @@ async function foo() {
const x = await bar();
return x;
}

async function foo() {
try {
return await bar();
} catch (error) {}
}
```

In the last example the `await` is necessary to be able to catch errors thrown from `bar()`.

## When Not To Use It

If you want to use `await` to denote a value that is a thenable, even when it is not necessary; or if you do not want the performance benefit of avoiding `return await`, you can turn off this rule.
Expand Down

0 comments on commit cdb1488

Please sign in to comment.