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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.