diff options
| author | Jared Forsyth | 2013-08-30 10:47:55 -0600 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-09-19 14:51:50 +0100 |
| commit | 022cb3dc4ef51b6bdda21f5e9f8c2ea00986c321 (patch) | |
| tree | e47ebd9bf914857a3ffaae40963501403d686cf9 /src/ng/exceptionHandler.js | |
| parent | 4f107acfcfc141555cf4419e5f9b4c89199a49d5 (diff) | |
| download | angular.js-022cb3dc4ef51b6bdda21f5e9f8c2ea00986c321.tar.bz2 | |
docs($exceptionHandler): add an example of overriding the handler
Closes #3816
Diffstat (limited to 'src/ng/exceptionHandler.js')
| -rw-r--r-- | src/ng/exceptionHandler.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ng/exceptionHandler.js b/src/ng/exceptionHandler.js index 2adc3f17..c3795bb7 100644 --- a/src/ng/exceptionHandler.js +++ b/src/ng/exceptionHandler.js @@ -9,10 +9,24 @@ * 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. * + * ## 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 {string=} cause optional information about the context in which * the error was thrown. |
