Sha256: 4c4a6f2b0f909afc99dcced6d576e610f7ae632cf42665a9a3328099aa154de8

Contents?: true

Size: 1.32 KB

Versions: 34

Compression:

Stored size: 1.32 KB

Contents

// Error Handling Service
// ----------------------
// This module is responsible for handling errors and show suitable messages to user.
// It's neccessary to use this service in your code. Make sure to specify this module
// as your module dependency
var Errors = angular.module("Errors", []);

// Error service defination
Errors.factory('catch_error', ["gettext", function(gettext) {

    return function(error) {
        if ("data" in error) {
            if ((typeof(error.data) == "object") && ("fields" in error.data)) {
                _.each(error.data.fields, function(value, key) {
                    $("#id_" + key).addClass("input-error");
                    _.each(value, function(x){
                        $("#id_" + key + "_msg").append(value);
                        $("#id_" + key + "_msg").addClass("error");

                    });
                });
                error_message(gettext("Validation error. Fixup errors first."));
                return;
            }
            if ((typeof(error.data) == "object") && ("error" in error.data)) {
                console.log(error.data.error);
                error_message(error.data.error);
                return;
            }
        }
        console.log(error);
        error_message(gettext("Unkown error: please try again or contact to administrator."));
    };
}]);

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
faalis-1.0.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-1.0.0.alpha4 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-1.0.0.alpha3 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-1.0.0.alpha2 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-1.0.0.alpha1 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-1.0.0.alpha0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.26.3 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.26.2 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.26.1 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.26.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.25.1 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.25.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.24.4 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.24.3 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.24.2 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.24.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.23.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.22.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.21.1 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.21.0 app/assets/javascripts/faalis/dashboard/modules/errors.js