Sha256: c4563d79e457fb5e884d499b91fab0e6882df8b477c8fbb8c0d97eb977f9916a

Contents?: true

Size: 1.48 KB

Versions: 33

Compression:

Stored size: 1.48 KB

Contents

(function () {
    'use strict';

    /**
     * @ngdoc service
     * @name  Bastion.common.service:ApiErrorHandler
     *
     * @description
     *   Provides common functionality in handling Katello/Foreman API Errors.
     */
    function ApiErrorHandler(translate, GlobalNotification) {
        this.handleGETRequestErrors = function (response, $scope) {
            var hasScopeErrorMessages = $scope && $scope.hasOwnProperty('errorMessages');

            if (response.hasOwnProperty('data') && response.data.hasOwnProperty('errors')) {
                if (hasScopeErrorMessages) {
                    $scope.errorMessages = response.data.errors;
                } else {
                    angular.forEach(response.data.errors, function (error) {
                        GlobalNotification.setErrorMessage(error);
                    });
                }
            } else {
                if (hasScopeErrorMessages) {
                    $scope.errorMessages = [translate('Something went wrong when retrieving the resource.')];
                } else {
                    GlobalNotification.setErrorMessage(translate('Something went wrong when retrieving the resource.'));
                }
            }

            if ($scope && $scope.hasOwnProperty('panel')) {
                $scope.panel.error = true;
            }
        };
    }

    angular.module('Bastion.common').service('ApiErrorHandler', ApiErrorHandler);

    ApiErrorHandler.$inject = ['translate', 'GlobalNotification'];

})();

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
katello-3.4.0.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.4.0.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.3.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.4.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.4.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.4.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.3.1.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.3.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.3.0.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.3.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.3.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.3.0.rc1.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.3.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.2.1.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.2.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.2.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.2.0.rc3 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.2.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.2.0.rc1.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.2.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js