Skip to content

Commit

Permalink
Prefer try-catch
Browse files Browse the repository at this point in the history
Co-authored-by: Morgan Roderick <20321+mroderick@users.noreply.github.com>
  • Loading branch information
mantoni and mroderick committed May 7, 2021
1 parent d97c874 commit 2c6927f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions test/promise-test.js
Expand Up @@ -6,15 +6,13 @@ var { assert, refute } = require("@sinonjs/referee");
async function getPromiseStatus(promise) {
var status = "pending";
var value = null;
promise
.then(function (val) {
status = "fulfilled";
value = val;
})
.catch(function (reason) {
status = "rejected";
value = reason;
});
try {
status = "fulfilled";
value = await promise;
} catch (reason) {
status = "rejected";
value = reason;
}
await new Promise(function (resolve) {
setTimeout(resolve, 0);
});
Expand Down

0 comments on commit 2c6927f

Please sign in to comment.