jquerymobile-router icon indicating copy to clipboard operation
jquerymobile-router copied to clipboard

Debugging snippet gets in the way

Open mzedeler opened this issue 11 years ago • 4 comments

This snippet:

var DEBUG = true;
function debug(err){
  if (DEBUG) {
    console.log(err);
    if (err.stack){ console.log(err.stack); }
  }
}

Seems to get more in the way than actually helping because Internet Explorer doesn't have a console object, so using debug in a try-catch block will just throw away what really went wrong and replace the actual error with something else.

I have two proposals to resolve this:

  • Remove this function and all references to it.
  • Expose an attribute that can contain a reference to a callback that receives debug calls.

I can implement both of the above, so just let me know which one and I'll do it.

mzedeler avatar May 13 '13 07:05 mzedeler

I'd go for the second solution. Adding a configuration option [defaulting to console.log, if console.log() exists and nothing is provided by the user] to pass the debug handler seems a safer way to handle this problem.

azicchetti avatar May 13 '13 08:05 azicchetti

Ok. I'll get to work on it.

(Unless you want to, of course.)

mzedeler avatar May 13 '13 09:05 mzedeler

I'm a little busy a.t.m., any help is greatly appreciated. But don't worry, if you don't have time to write the patch, I think I can push the change (plus another small feature someone suggested via email) in the next few days.

Thank you for spotting the issue

azicchetti avatar May 13 '13 09:05 azicchetti

I won't be able to fix it until some time this wednesday. I'll just check the issue here by then to see if you have a fix ready.

mzedeler avatar May 13 '13 12:05 mzedeler