Created
December 15, 2014 15:31
-
-
Save xcarpentier/21fd5ebac309b91a3306 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* recommandé */ | |
angular | |
.module('blocks.exception') | |
.config(exceptionConfig); | |
exceptionConfig.$inject = ['$provide']; | |
function exceptionConfig($provide) { | |
$provide.decorator('$exceptionHandler', extendExceptionHandler); | |
} | |
extendExceptionHandler.$inject = ['$delegate', 'toastr']; | |
function extendExceptionHandler($delegate, toastr) { | |
return function (exception, cause) { | |
$delegate(exception, cause); | |
var errorData = { | |
exception: exception, | |
cause: cause | |
}; | |
/** | |
* Peut ajouter l'erreur dans un service qui les collecte | |
* ajouter l'erreur au $rootScope, envoyer l'erreur à un serveur, | |
* ou un log local. Ou lever l'exception. C'est une décision qui vous revient. | |
* throw exception; | |
*/ | |
toastr.error(exception.msg, errorData); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment