mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 23:40:23 +00:00
Update src/ng/exceptionHandler.js
Here's an iniitla attempt at documenting how one might write a
test using $exceptionHandlerProvider. The key take-away is the use
of this pattern:
it(...
module(...
$exceptionHandlerProvider.mode('log');
});
inject(...
);
});
27 lines
810 B
JavaScript
27 lines
810 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* @ngdoc function
|
|
* @name ng.$exceptionHandler
|
|
* @requires $log
|
|
*
|
|
* @description
|
|
* Any uncaught exception in angular expressions is delegated to this service.
|
|
* The default implementation simply delegates to `$log.error` which logs it into
|
|
* the browser console.
|
|
*
|
|
* In unit tests, if `angular-mocks.js` is loaded, this service is overridden by
|
|
* {@link ngMock.$exceptionHandler mock $exceptionHandler} which aids in testing.
|
|
*
|
|
* @param {Error} exception Exception associated with the error.
|
|
* @param {string=} cause optional information about the context in which
|
|
* the error was thrown.
|
|
*
|
|
*/
|
|
function $ExceptionHandlerProvider() {
|
|
this.$get = ['$log', function($log){
|
|
return function(exception, cause) {
|
|
$log.error.apply($log, arguments);
|
|
};
|
|
}];
|
|
}
|