03_비동기예외처리
1. Error와 Exception의 차이
1. 비동기 상황에서의 예외처리
const foo = async () => {} // 1. then에 두번째 인자 넣기 foo().then(()=>{ console.log("success") // onfulfilled }, (e)=>{ console.log(e) // onRejected } ) // 2. .catch() 함수로 받기 foo().catch((e) => { console.error(e); }); // 3. try catch 구문 안에 await 사용하기 try { await foo(); } catch (e) { console.error(e); } // 4. await과 catch문을 동시에 사용하기 await foo().catch((e)=>{console.error(e)})
Last updated