Just to report a detail, (in my environment) errors that occur within the body of Promise.resolve({<body>}) are not "Catched":
Promise.resolve({<body>})
Promise.resolve((()=>{throw "oops"; })()) .catch(e=>console("Catched ",e)); // escapes, "Error: oops" reported further up
but error occurring in the body of a proper Promise are "Catched":
Promise
(new Promise((resolve,reject)=>{ resolve((()=>{throw "oops"})()) })) .catch(e=>console.log("Catched ",e)); // Catched oops
How about this assertion:
async function fn() { <body> }
is semantically equivalent to
function fn() { return new Promise((resolve,reject)=>{ resolve({ <body> }) }) }
Corrollary: The following is only a Proper Promise if <body> is a proper Promise:
<body>
function fn() { return Promise.resolve({<body}); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Just to report a detail, (in my environment) errors that occur within the body of
Promise.resolve({<body>})
are not "Catched":but error occurring in the body of a proper
Promise
are "Catched":How about this assertion:
is semantically equivalent to
Corrollary:
The following is only a Proper Promise if
<body>
is a proper Promise: