From 8e8cc5c0015490ff73d4af2bc8c908f00513e75f Mon Sep 17 00:00:00 2001 From: Jared Forsyth Date: Fri, 30 Aug 2013 10:47:55 -0600 Subject: [PATCH] adding an example of how to override the exceptionHandler --- src/ng/exceptionHandler.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ng/exceptionHandler.js b/src/ng/exceptionHandler.js index 2adc3f171e03..f30df7918336 100644 --- a/src/ng/exceptionHandler.js +++ b/src/ng/exceptionHandler.js @@ -9,6 +9,20 @@ * 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. + * + * Example override: + * + *
+ *   angular.module('exceptionOverride', []).factory('$exceptionHandler', function () {
+ *     return function (exception, cause) {
+ *       exception.message += ' (caused by "' + cause + '")';
+ *       throw exception;
+ *     };
+ *   });
+ * 
+ * + * This will make angular exceptions fail hard when they happen instead of just + * complaining to the console. * * In unit tests, if `angular-mocks.js` is loaded, this service is overridden by * {@link ngMock.$exceptionHandler mock $exceptionHandler} which aids in testing.