簡體   English   中英

是否與捕獲相​​反?

[英]Is there an opposite of catch?

通過運行以下命令,您可以在拋出錯誤時運行代碼。

try {
    // test
} catch (e) {
    // error output
}

是否有類似的方式只在沒有拋出錯誤的情況下運行代碼?

當然有,請看內聯評論。

try {
// test
// No error is thrown if program control reaches here
} catch {
// error output
}

如果您不希望外部catch任何其他錯誤,請考慮在“No error are thrown”部分中使用其他try塊。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM