【发布时间】:2019-07-06 01:31:19
【问题描述】:
我的项目有错误,我需要使用 try、catch 和 finally 来处理。
我可以在 JavaScript 中使用它,但不能在 Typescript 中使用。
当我将 Exception 作为 typescript catch 语句中的参数时,为什么它不接受这个?
这里是代码。
private handling(argument: string): string {
try {
result= this.markLibrary(argument);
}
catch(e:Exception){
result = e.Message;
}
return result;
}
我在这里需要一条异常消息,但我无法得到。我得到了以下错误。
Catch 子句变量不能有类型注释。
【问题讨论】:
标签: typescript error-handling try-catch