PDA

View Full Version : merging this code


snake_eyes
06-04-2007, 07:52 AM
Hello,

I have the following code:

var ErrorsHandler = {
handleError: function(errorMsg, errorUrl, errorLine)
{
if( Config.ErrorsHandlerOnce &&
ErrorsHandler.lastErrorUrl == errorUrl &&
ErrorsHandler.lastErrorMsg == errorMsg &&
ErrorsHandler.lastErrorLine == errorLine ){
return true;
}

if(Config.ErrorsHandlerLog){
(new Image).src = Config.ErrorsHandlerURL +
"?errorUrl=" + escape(errorUrl) +
"&errorLine=" + escape(errorLine) +
"&errorMsg=" + escape(errorMsg);
}
if(Config.ErrorsHandlerDebug){
alert('----------------------------------\n\n' +
' Error URL : ' + errorUrl + '\n\n' +
' Error Line : ' + errorLine + '\n\n' +
' Error Message: ' + errorMsg + '\n\n' +
'----------------------------------') ;
}

ErrorsHandler.lastErrorUrl = errorUrl;
ErrorsHandler.lastErrorMsg = errorMsg;
ErrorsHandler.lastErrorLine = errorLine;

return true;
}
};
window.onerror = ErrorsHandler.handleError;

how do I merge the above code in the ajax request in order to utilize it to handle all the errors

Regards heaps,

A1ien51
06-11-2007, 01:16 PM
You want to capture errors that are generated from the XMLHttpRequest Object? Is that what you are talking about?

Eric

snake_eyes
06-11-2007, 01:24 PM
You want to capture errors that are generated from the XMLHttpRequest Object? Is that what you are talking about?

Eric

Yes, this what I need, how to capture errors that are generated from the XMLHttpRequest object!

Any idea please?

Regards

A1ien51
06-11-2007, 02:10 PM
Well you can send in the status, statusText, and I would send in some other parameter that corresponds to the Ajax Call. Not sure what your request functionality looks like so I can not recommend anything more concrete.

Eric

snake_eyes
06-11-2007, 02:48 PM
Yes I know that it can :) but how? is there an example please?

Regards

rnd me
06-15-2007, 07:52 AM
i can't see all of "Config", but this looks suspisious:


if( Config.ErrorsHandlerOnce &&
ErrorsHandler.lastErrorUrl == errorUrl &&
ErrorsHandler.lastErrorMsg == errorMsg &&


change to: (just remove the 1st line...)

if( ErrorsHandler.lastErrorUrl == errorUrl &&
ErrorsHandler.lastErrorMsg == errorMsg &&

snake_eyes
06-15-2007, 11:32 AM
Hello,

Thanks for all, I would like to mention you that this code is copy / paste from a site so, is there any idea to how to merge it and is there any example

thanks