Async/Await Try Catch
NodeJS
Medium
3 views
Problem Description
Call an async function that can throw and handle it cleanly.
Output Format
Print OK or ERROR.
Constraints
Return a rejected promise and catch it.
Official Solution
async function risky() {
throw new Error('meetcode failed');
}
(async () => {
try {
await risky();
console.log('OK');
} catch (e) {
console.log('ERROR');
}
})();
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!