Greetings Naresh Tank, I have come up with a solution to address your issue by monitoring all ajax requests. This approach allows you to customize the error message regardless of whether it originates from a store or a form.
I trust that this will be beneficial to you.
Here is the code snippet from app.js:
init: function() {
this.addAjaxErrorHandler(this);
},
addAjaxErrorHandler: function(object) {
Ext.Ajax.on('requestexception', function(conn, response, options, e) {
var statusCode = response.status,
errorText = null,
captionText = response.statusText;
if (statusCode === 0 || statusCode === 401) {
Ext.Ajax.abortAll();
}
if(response.statusText==="Authorization Required"){
Ext.Ajax.abortAll();
}
// 404 - file or method not found - special case
if (statusCode == 404) {
Ext.MessageBox.alert('Error 404', 'URL ' + response.request.options.url + ' not found');
return;
}
if (response.responseText !== undefined) {
var r = Ext.decode(response.responseText, true);
if (r !== null) {
errorText = r.ErrorMessage;
}
if (errorText === null)
errorText = response.responseText;
}
if (!captionText)
captionText = 'Error ' + statusCode;
Ext.MessageBox.alert(captionText, errorText);
},
object);
Ext.Ajax.on('requestcomplete', function(conn, response, options, e) {
var statusCode = response.status,
errorText = null,
captionText = response.statusText;
if (response.responseText !== undefined) {
var r = Ext.decode(response.responseText, true);
if (r !== null && r.success === false) {
try{
if(typeof r.data[0].idUsr !== 'undefined')
return;
}catch(e){}
errorText = r.msg;
if (errorText === null)
errorText = response.responseText;
if (!captionText)
captionText = 'Error ' + statusCode;
Ext.MessageBox.alert(captionText, errorText);
}
}
},
object);
};