Sha256: 38b652a625bfa2955388e4c4086c82c31b9c04ec45b4760cb31291aa2aee1332

Contents?: true

Size: 1.68 KB

Versions: 44

Compression:

Stored size: 1.68 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, Notification) {
        function handleError(response, $scope, defaultErrorMessage) {
            if (response.hasOwnProperty('data') && response.data.hasOwnProperty('errors')) {
                angular.forEach(response.data.errors, function (error) {
                    Notification.setErrorMessage(error);
                });
            } else {
                Notification.setErrorMessage(defaultErrorMessage);
            }

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

        this.handleGETRequestErrors = function (response, $scope) {
            var defaultErrorMessage = translate('Something went wrong when retrieving the resource.');
            handleError(response, $scope, defaultErrorMessage);
        };

        this.handlePUTRequestErrors = function (response, $scope) {
            var defaultErrorMessage = translate('Something went wrong when saving the resource.');
            handleError(response, $scope, defaultErrorMessage);
        };

        this.handleDELETERequestErrors = function (response, $scope) {
            var defaultErrorMessage = translate('Something went wrong when deleting the resource.');
            handleError(response, $scope, defaultErrorMessage);
        };
    }

    angular.module('Bastion.common').service('ApiErrorHandler', ApiErrorHandler);
    ApiErrorHandler.$inject = ['translate', 'Notification'];
})();

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
katello-3.15.3.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.3 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.1.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.0.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.0.rc1.3 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.0.rc1.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.0.rc1.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.15.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.14.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.13.4 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.14.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.13.3 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.14.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.13.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.14.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.13.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js