为什么Google Closure认为Exception未定义?

3
我尝试使用 Google Closure Compiler 并在我的代码中添加了 -W VERBOSE 参数。
这个简单的语句。
throw new Exception ("hello");

产生了一个错误。
variable Exception is undeclared

我认为Exception是标准的。是闭包错误,还是我应该在抛出异常之前声明异常?(我的代码在Firefox中运行良好。)
1个回答

3

你应该抛出 Error 而不是 Exception:

throw new Error('hello');

在我的Firefox中,throw new Exception()不起作用,不确定为什么它能在你那里工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接