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

adding an example of how to override the exceptionHandler #3816

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/ng/exceptionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
* <pre>
* angular.module('exceptionOverride', []).factory('$exceptionHandler', function () {
* return function (exception, cause) {
* exception.message += ' (caused by "' + cause + '")';
* throw exception;
* };
* });
* </pre>
*
* 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.
Expand Down