mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 23:34:42 +00:00
docs($exceptionHandler): add an example of overriding the handler
Closes #3816
This commit is contained in:
parent
c20b569dbe
commit
666705c0a4
1 changed files with 15 additions and 1 deletions
|
|
@ -9,10 +9,24 @@
|
||||||
* Any uncaught exception in angular expressions is delegated to this service.
|
* Any uncaught exception in angular expressions is delegated to this service.
|
||||||
* The default implementation simply delegates to `$log.error` which logs it into
|
* The default implementation simply delegates to `$log.error` which logs it into
|
||||||
* the browser console.
|
* the browser console.
|
||||||
*
|
*
|
||||||
* In unit tests, if `angular-mocks.js` is loaded, this service is overridden by
|
* In unit tests, if `angular-mocks.js` is loaded, this service is overridden by
|
||||||
* {@link ngMock.$exceptionHandler mock $exceptionHandler} which aids in testing.
|
* {@link ngMock.$exceptionHandler mock $exceptionHandler} which aids in testing.
|
||||||
*
|
*
|
||||||
|
* ## Example:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* angular.module('exceptionOverride', []).factory('$exceptionHandler', function () {
|
||||||
|
* return function (exception, cause) {
|
||||||
|
* exception.message += ' (caused by "' + cause + '")';
|
||||||
|
* throw exception;
|
||||||
|
* };
|
||||||
|
* });
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
* @param {Error} exception Exception associated with the error.
|
* @param {Error} exception Exception associated with the error.
|
||||||
* @param {string=} cause optional information about the context in which
|
* @param {string=} cause optional information about the context in which
|
||||||
* the error was thrown.
|
* the error was thrown.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue