You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
the await-to-js readme does not mention the different between using method 1(try catch) and method 2(await-to-js).
but their use in reject is different.
For example:
function returnPromise() {
return Promise.reject();
}
1.when use try catch:
try {
const res = await this.returnPromise();
console.log("res", res);
console.log("first case normal process");
} catch (err) {
console.log("err", err);
console.log("first case abnormal process");
}
err is undefined,but "first case abnormal process" can output normally.
2.when use await-to-js
const [err, res] = await to(this.returnPromise());
if (res) {
console.log("res", res);
console.log("second case normal process");
} else if (err) {
console.log("err", err);
console.log("second case abnormal process");
}
err is undefined, so "second case abnormal process" cannot output normally.
Expect:
if await-to-js error is undefined, return default error(new Error() or other).
The text was updated successfully, but these errors were encountered:
Hi,
the await-to-js readme does not mention the different between using method 1(try catch) and method 2(await-to-js).
but their use in reject is different.
For example:
1.when use try catch:
err is undefined,but "first case abnormal process" can output normally.
2.when use await-to-js
err is undefined, so "second case abnormal process" cannot output normally.
Expect:
if await-to-js error is undefined, return default error(new Error() or other).
The text was updated successfully, but these errors were encountered: