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-0.20.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.19.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.18.1 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.18.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.17.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.16.3 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.16.1 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.16.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.15.1 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.15.0 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.14.4 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.14.3 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.14.2 app/assets/javascripts/faalis/dashboard/modules/errors.js
faalis-0.14.0 app/assets/javascripts/faalis/dashboard/modules/errors.js