通过运行以下代码,您可以在抛出错误时运行代码。
try {
// test
} catch (e) {
// error output
}
是否有类似的方法仅在没有错误被抛出时运行代码?
最佳答案
当然有,请查看内联评论。
try {
// test
// No error is thrown if program control reaches here
} catch {
// error output
}
如果您不希望外部 catch
处理任何其他错误,请考虑在“不引发错误”部分中使用额外的 try
block 。
关于javascript - catch 有反义词吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38179977/