主要用法:
try {
throw new Error('手动抛出异常');
} catch (error) {
console.log(error);
} finally {
console.log('执行了finally语句块');
}
执行结果:
PS E:\Code\TypeScript\12.TypeScript对象> node .\test03.ts
Error: 手动抛出异常
at Object.<anonymous> (E:\Code\TypeScript\12.TypeScript对象\test03.ts:2:11)
at Module._compile (internal/modules/cjs/loader.js:1075:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1096:10)
at Module.load (internal/modules/cjs/loader.js:940:32)
at Function.Module._load (internal/modules/cjs/loader.js:781:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
执行了finally语句块