0

I am testing to rewrite som XMLHttpRequest-code with HTML5 Promise.

I did a mistake and the code in thePromise.then(failingCode) failed. This give a call to the reject function used when setting up the Promise.

I had to search a while to catch the error since I did not get any Call stack and no line number where the error occured.

That is of course very inconvenient.

How should I handle this? Should I send a bug report to the Google Chrome developers? Or, is it my own fault?

jib
  • 40,579
  • 17
  • 100
  • 158
Leo
  • 4,136
  • 6
  • 48
  • 72
  • 1
    To be fair help is on its way: https://github.com/jquery/jquery/issues/1722#issuecomment-70754912 – Benjamin Gruenbaum Jan 23 '15 at 13:07
  • That looks nice, @BenjaminGruenbaum! Though it actually does not help to find the exact location of the problem. You can combine it with me answer here below. That gives some extra information. (So it looks like I should file another bug report for Chrome.) – Leo Jan 23 '15 at 23:57
  • There _is_ a way to get the call stack in Google Chrome - that way is async stack traces and you can see it in the link I posted above. If you want to always have it don't use native promises use Bluebird which stitches stack traces and has much better traces. – Benjamin Gruenbaum Jan 24 '15 at 09:44
  • 1
    Works fine in Firefox. This question should be tagged as google-chrome. – jib Jan 26 '15 at 17:53
  • Thanks @jib, I was not aware of the tag. – Leo Feb 12 '15 at 18:21

1 Answers1

-1

I just realized that there is a way to get the call stack in Google Chrome. Though it is a bit inconvenient you can do like this:

function failingCode(arg) {
    try {
        ... the failing code ...
    } catch(e) {
        console.log("failingCode error: "+e.stack);
        debugger;
    }
}

Please notice that if you throw an error you need to use the Error function to get a stack. (Simply throw "my message" will not give a stack.)

UPDATE Reported as a Chrome bug here: https://code.google.com/p/chromium/issues/detail?id=458306

Leo
  • 4,136
  • 6
  • 48
  • 72
  • 1
    I think you'll want to read http://stackoverflow.com/a/28427407/1048572. There is good debug tooling coming for promises. – Bergi Feb 12 '15 at 22:31