Exception handling

30 views
Skip to first unread message

Marco Marigo

unread,
Dec 7, 2012, 6:17:22 AM12/7/12
to extdirec...@googlegroups.com
Hi Gian Marco!

Is it possible to handle exceptions directly on client method handler?

//server code
   public class EchoService
    {
        public string Echo(string value)
        {
            throw new ApplicationException("An error occured");
            return value;
        }
    }

// client code
EchoService.echo('hello world!', function (result) {
    // Can I detect here if a server exception occurred?
    console.log(result);
});

I know I can catch server exception in this way:
Ext.direct.Manager.on('exception', function (event) {
    alert(Ext.encode(event))
});

But I don't like it and besides 'function (result) { }' is called with result = null and I don't know if there was an axception.

Thanks.
Marco

Marco Marigo

unread,
Dec 7, 2012, 6:58:09 AM12/7/12
to extdirec...@googlegroups.com
I tried to add a param (event) to the client method handler and I discovered that I have all the informations I need in case of exceptions.

Marco


Gian Marco Gherardi

unread,
Dec 7, 2012, 7:03:55 AM12/7/12
to extdirec...@googlegroups.com
Yes, this is how i call ExtDirect methods:

Server.method('param1', 'param2', function (returnValue, event) {
    if (!event.status) {
        // error
    } else {
   // no error
    }
});


Gian Marco Gherardi
http://gianmarco.gherardi.me
Reply all
Reply to author
Forward
0 new messages