Emerjoin / Hi-Framework-features

Java EE Framework
5 stars 1 forks source link

Frontiers - set global handlers #38

Closed emjunior258 closed 8 years ago

emjunior258 commented 8 years ago

The template should look like this:

    Hi.template({

    someVariable: "Some String Value",

    $frontiers:{

        //This handler is overridden by specific handlers

        forbbiden : function(call){

        },

        timeout : function(call){

        },

        offline : function(call){

        },

        interrupted : function(call){

        },

        catch : function(call,error){

        },

        overrequest : function(call){

        },

        finally : function(call){

        }

    }

});
emjunior258 commented 8 years ago

The best way to catch exceptions globally is to set a message on the promise to be exhibited by the global handler. The global handler receives the promise as first argument to be

Frontier1.getFullName("Mario", "Junior")
     .try(function (data) {

            console.log(data);

      }).errorMessage = "The method error message";

The global handler would display an error message this way:


catch : function(call){

    doSomething(call.errorMessage);

}