Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 666705c

Browse files
jaredlypetebacondarwin
authored andcommitted
docs($exceptionHandler): add an example of overriding the handler
Closes #3816
1 parent c20b569 commit 666705c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/ng/exceptionHandler.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,24 @@
99
* Any uncaught exception in angular expressions is delegated to this service.
1010
* The default implementation simply delegates to `$log.error` which logs it into
1111
* the browser console.
12-
*
12+
*
1313
* In unit tests, if `angular-mocks.js` is loaded, this service is overridden by
1414
* {@link ngMock.$exceptionHandler mock $exceptionHandler} which aids in testing.
1515
*
16+
* ## Example:
17+
*
18+
* <pre>
19+
* angular.module('exceptionOverride', []).factory('$exceptionHandler', function () {
20+
* return function (exception, cause) {
21+
* exception.message += ' (caused by "' + cause + '")';
22+
* throw exception;
23+
* };
24+
* });
25+
* </pre>
26+
*
27+
* This example will override the normal action of `$exceptionHandler`, to make angular
28+
* exceptions fail hard when they happen, instead of just logging to the console.
29+
*
1630
* @param {Error} exception Exception associated with the error.
1731
* @param {string=} cause optional information about the context in which
1832
* the error was thrown.

0 commit comments

Comments
 (0)