Angular.js 默认不提供人类可读的错误消息。
有没有办法将默认的、神秘的 Angular.js 异常 URL 更改为更易读的错误消息?事实上,我必须复制 URL,删除前缀,然后粘贴到浏览器中以查看问题所在。
例如,将下面的异常转化为更有用的错误信息:
Error: [ng:areq] http://errors.angularjs.org/1.3.0/ng/areq?p0=InterfaceController&p1=not%20a%20function%2C%20got%20undefined y/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular....
类似于:
"Missing required argument to InterfaceController"
我知道我可以提供我自己的异常处理程序:
.factory('$exceptionHandler', function () {
return function errorCatcherHandler(exception, cause) {
console.error(exception);
};
});
我是不是处理错了?
最佳答案
问题是我正在针对缩小/压缩版本进行开发(假设它与其他 JS 库一样)。 未压缩 版本包含一条可读的错误消息。
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js
关于javascript - 可读的 Angular.js 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26512323/