Skip to content

Commit cdb1488

Browse files
q42jaapilyavolodin
authored andcommittedDec 1, 2017
Docs: Adds an example with try/catch. (#9672)
* 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
1 parent 58216b6 commit cdb1488

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎docs/rules/no-return-await.md

+8
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,16 @@ async function foo() {
3030
const x = await bar();
3131
return x;
3232
}
33+
34+
async function foo() {
35+
try {
36+
return await bar();
37+
} catch (error) {}
38+
}
3339
```
3440

41+
In the last example the `await` is necessary to be able to catch errors thrown from `bar()`.
42+
3543
## When Not To Use It
3644

3745
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.

0 commit comments

Comments
 (0)
Please sign in to comment.