PDA

View Full Version : How to handle all exception when calling remote method



hudi1
31 May 2013, 1:49 AM
Hi,

I have no store or model. Just some buttons with actions

for example:

onSearchPersonClick : function() {
console.log("onSearchPersonClick");
simpleService.doEcho("aaa", function(result, e) {
console.log(e.message);
});
},

How I can handle all this action and when some exception occurs (Response: [{"type":"exception","message":"aaaaaaaaaaaaaa" ... ) just show windows with this error message ?

existdissolve
31 May 2013, 3:17 AM
I'm assuming that doEcho() is some wrapper for making an Ext.Ajax.request() (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Ajax-method-request)? If so, check out the requestexception event: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Ajax-event-requestexception

hudi1
31 May 2013, 3:40 AM
ok I got it. I need to add Manager.on to my app:

Ext.require('Ext.direct.*', function() {
Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
Ext.direct.Manager.on('exception', function(e) {
Ext.Msg.alert('Error', e.message);
});
});