⤴️try-catch-finally

🚧 under construction

(statement)

try { ... }            // run code that may throw.
catch (err) { ... }    // error handling (and∨ rethrow)
finally { ... }        // cleanup code

一但使用 try,一定要用 catch(err) 去抓「所有的錯誤」,否則可能會漏掉自己沒有預期的錯誤

try {
  noSuchFunc();  // ⛔ ReferenceError (not catched)
} catch(err) { 
  // `console.log(err)` omitted ... (dangerous)❗
  // or, `throw err` omitted ...
}
// the code will continue executing happily❗

Last updated