示例

try {
	console.log('正常执行1');
  console.log(a);
  console.log('正常执行2');
} catch(e) {
	console.log('e->', e);
  console.log('e.name->', e.name);
  console.log('e.message->', e.message);
}

Untitled

try 中的错误,不影响外部代码和 finally 中代码的执行

try {
	console.log('正常执行1');
  console.log(a);
  console.log('正常执行2');
} catch(e) {
	console.log('e->', e);
  console.log('e.name->', e.name);
  console.log('e.message->', e.message);
} finally {
	console.log('正常执行3');
}
console.log('正常执行4');

Untitled

throw 手动抛错

throw '出错啦'

Untitled