자바스크립트에도 에러를 확인 할수있는 try catch 문이 있다.

뭐~ console.log를 사용해서 볼수 도 있겠지만 try catch 문을 이용해야 하는 경우도 있으니 알아두면 좋을것 같다.

 

 

try {
    addalert("bad call");
}
catch(e) {
    document.write ("Error Message: " + e.message);
    document.write ("<br />");
    document.write ("Error Code: ");
    document.write (e.number & 0xFFFF);
    document.write ("<br />");
    document.write ("Error Name: " + e.name);
}

// Output:
Error Message: 'addalert' is undefined
Error Code: 5009
Error Name: ReferenceError

 

+ Recent posts

자바스크립트에도 에러를 확인 할수있는 try catch 문이 있다.

뭐~ console.log를 사용해서 볼수 도 있겠지만 try catch 문을 이용해야 하는 경우도 있으니 알아두면 좋을것 같다.

 

 

try {
    addalert("bad call");
}
catch(e) {
    document.write ("Error Message: " + e.message);
    document.write ("<br />");
    document.write ("Error Code: ");
    document.write (e.number & 0xFFFF);
    document.write ("<br />");
    document.write ("Error Name: " + e.name);
}

// Output:
Error Message: 'addalert' is undefined
Error Code: 5009
Error Name: ReferenceError

 

+ Recent posts