©
이 문서에서는PHP 중국어 웹사이트 매뉴얼풀어 주다
Any uncaught exception in Angular表达式s is delegated to this service. The default implementation simply delegates to$log.error
which logs it into the browser console.
In unit tests, ifangular-mocks.js
is loaded, this service is overridden by mock $exceptionHandler which aids in testing.
angular.module('exceptionOverride',[]).factory('$exceptionHandler',Function(){returnFunction(exception,cause){exception.message+=' (caused by "'+cause+'")';throwexception;};});
This example will override the normal action of$exceptionHandler
, to make angular exceptions fail hard when they happen, instead of just logging to the console.
$log
$exceptionHandler(exception,[cause]);
参数 | 类型 | 详述 |
---|---|---|
exception | Error | Exception associated with the error. |
cause
(可选)
|
string | optional information about the context in which the error was thrown. |