Code coverage report for app/components/_common/production/exception-handler.decorator.js

Statements: 100% (10 / 10)      Branches: 100% (0 / 0)      Functions: 100% (2 / 2)      Lines: 100% (8 / 8)      Ignored: none     

All files » app/components/_common/production/ » exception-handler.decorator.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                     
// Extend the original $exceptionHandler service.
// * add error log prefix using exceptionPrefixProvider
// * do other thing with error log
exceptionHandlerDecorator.$inject = ['$delegate', 'Logger'];
function exceptionHandlerDecorator ($delegate, logger) {
    return (exception, cause) => { // eslint-disable-line
        const appErrorPrefix = '[Aio Angular App Error] ';
        const errorData = {exception, cause};
        exception.message = appErrorPrefix + exception.message;
        // $delegate(exception, cause);
        /**
         * Could add the error to a service's collection,
         * add errors to $rootScope, log errors to remote web server,
         * or log locally. Or throw hard. It is entirely up to you.
         * throw exception;
         *
         * @example
         *     throw { message: 'error message we added' };
         */
        logger.error(exception.message, errorData);
    };
}
 
export default exceptionHandlerDecorator;