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.13.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.13.0.rc2.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.13.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.12.3 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.12.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.13.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.12.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.11.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.10.2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.12.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.12.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.10.1.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.12.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.10.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.11.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.11.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.11.0.rc2 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.11.0.rc1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.10.0 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js
katello-3.10.0.rc1.1 engines/bastion_katello/app/assets/javascripts/bastion_katello/common/api-error-handler.service.js