try { // 尝试执行逻辑代码 throw '这是一个自定义错误!' } catch(err) { // 捕获错误 console.log(`捕获的错误信息:${err}`) } finally { // 无论是否报错,在最后必须执行的代码 }