- try 如過錯誤會在 catch 接住把錯誤印出來,而 final 不管有沒有錯誤都會執行
try {
...
}
catch(e) {
console.log(e);
}
final {
...
}
- nest try catch throw 則會把錯誤丟到外層
try {
...
try {
...
}
catch(e) {
console.log(e);
throw(e); // 把錯誤丟到外層
}
}
catch(e) {
console.log(e);
}
final {
...
}
沒有留言:
張貼留言