Hint
await unwraps Promise rejections into thrown errors. try/catch works naturally with async/await.
async function failingTask() {
throw new Error('task failed');
}
async function main() {
try {
await failingTask();
console.log('success');
} catch (e) {
console.log('caught: ' + e.message);
}
}
main();caught: task failed
Explanation: async functions wrap throws in rejected Promises. await converts rejection back to a thrown error that try/catch handles.
Key Insight: await unwraps Promise rejections into thrown errors. try/catch works naturally with async/await.