Skip to content

Instantly share code, notes, and snippets.

@newtriks
Created Jul 8, 2014
Embed
What would you like to do?
Example using provider and ng-mixin
angular.module('app', []).config(require('./common/exceptions’));
'use strict';
var mix = require('ng-mixin');
module.exports = mix({
$inject: ['$provide'],
init: function ($provide) {
$provide.decorator('$exceptionHandler', ['$delegate', '$injector',
function ($delegate, $injector) {
return function (exception, cause) {
if (exception.name === 'Exception') {
$injector.invoke(['$rootScope',
function ($rootScope) {
$rootScope.$broadcast('error', exception.message);
}
]);
} else {
$delegate(exception, cause);
}
};
}
]);
}
});
'use strict';
var mix = require('ng-mixin');
var ExceptionHandler = require('./exception-handler');
module.exports = function ($provide) {
return new ExceptionHandler($provide);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment