PDA

View Full Version : DataProxy default exception catcher gone



bobmanc
8 Mar 2011, 9:45 AM
I have been using the following at the top of my code to catch any generic server side errors.



Ext.data.DataProxy.on('exception', function(proxy, type, action, options, response) {
Ext.Msg.alert('Error',Ext.util.JSON.decode(response.responseText).errorMsg);
});


The latest release, pr3, appears to have eliminated DataProxy. I tried this with Proxy but it throws an error.

Anyone know how to accomplish this in the new version?

Dmoney
28 Mar 2011, 9:28 AM
Ext.decode(action.response.responseText);

bobmanc
29 Mar 2011, 11:42 AM
Huh? This does not answer my question.

westy
30 Mar 2011, 4:20 AM
You probably want ServerProxy, although it's exception raising is incomplete at present (there's a big TODO in there).

Personally I override afterRequest, but could probably accomplish the same with an exception event:


afterRequest: function(request, success) {
// FIXME: currently a bug in ServerProxy that doesn't set the success flag correctly, or pass any exception details:
// .....: http://www.sencha.com/forum/showthread.php?127501-PR5-ServerProxy-call-to-afterRequest-hard-codes-success-flag
// .....: http://www.sencha.com/forum/showthread.php?127503-PR5-ServerProxt-exception-event
if (!success || request.operation.hasException()) {
Ext.Msg.show({
title: 'Error',
msg: 'Failed to make request: FIXME: Add exception details',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
}
}

Francois Lecroart
26 Apr 2011, 6:36 AM
Is it possible to have an answers from sencha dev?
I use this function in Ext3 and i whant to know if i have to use the tips from westy or it's possible to have this feature in ext4?