<commit_before>/**
 * @ngdoc service
 * @name Volusion.toolboxCommon.vnHttpResponseInterceptor
 * @requires $q
 * @requires $rootScope
 * @description
 *
 * # vnHttpResponseInterceptor
 * This service is added as an interceptor to the $http module. This intercepts
 * the $http service and provides response and responseError handlers. If there
 * is a response error, it emits an event on the $rootScope with the key VN_HTTP_ERROR.
 * Any module using the `Volusion.toolboxCommon` module can add an event listener on the
 * $rootScope and take necessary action. The second parameter of the event listener
 * function contains the response status and data / message.
 *
 * @example
 *
 *  $rootScope.$on('VN_HTTP_ERROR', function(event, err) {
 *     // Logic to display error to user
 *  });
 *
 */
'use strict';

angular.module('Volusion.toolboxCommon')
    .factory('vnHttpResponseInterceptor', ['$q', '$rootScope', function($q, $rootScope) {

        return {
            response: function(response) {
                // response.status === 200
                return response || $q.when(response);
            },
            responseError: function(rejection) {

                if(rejection.status === 500) {
                    $rootScope.$emit('VN_HTTP_500_ERROR', {test: true, err :rejection} , { status: rejection.status, message: rejection.data, resource: rejection.headers('resource') || '' });
                }

                return $q.reject(rejection);
            }
        };

    }]);<commit_msg>Remove dev property.<commit_after>/**
 * @ngdoc service
 * @name Volusion.toolboxCommon.vnHttpResponseInterceptor
 * @requires $q
 * @requires $rootScope
 * @description
 *
 * # vnHttpResponseInterceptor
 * This service is added as an interceptor to the $http module. This intercepts
 * the $http service and provides response and responseError handlers. If there
 * is a response error, it emits an event on the $rootScope with the key VN_HTTP_ERROR.
 * Any module using the `Volusion.toolboxCommon` module can add an event listener on the
 * $rootScope and take necessary action. The second parameter of the event listener
 * function contains the response status and data / message.
 *
 * @example
 *
 *  $rootScope.$on('VN_HTTP_ERROR', function(event, err) {
 *     // Logic to display error to user
 *  });
 *
 */
'use strict';

angular.module('Volusion.toolboxCommon')
    .factory('vnHttpResponseInterceptor', ['$q', '$rootScope', function($q, $rootScope) {

        return {
            response: function(response) {
                // response.status === 200
                return response || $q.when(response);
            },
            responseError: function(rejection) {

                if(rejection.status === 500) {
                    $rootScope.$emit('VN_HTTP_500_ERROR', {err :rejection} , { status: rejection.status, message: rejection.data, resource: rejection.headers('resource') || '' });
                }

                return $q.reject(rejection);
            }
        };

    }]);
{'fraction_non_alphanumeric': 0.11514351699109204, 'fraction_numerical': 0.0059386341141537445, 'mean_word_length': 2.771144278606965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6810709', 'n_tokens_mistral': 859, 'n_tokens_neox': 802, 'n_words': 252}