Skip to content

Commit

Permalink
add stack debugging to .call
Browse files Browse the repository at this point in the history
  • Loading branch information
johnspackman committed Oct 30, 2019
1 parent 8b80e2c commit a438809
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion source/class/qx/util/Promisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,21 @@ qx.Class.define("qx.util.Promisify", {
});
},

call: function(fn) {
call: function(fn, debugStack) {
if (qx.core.Environment.get("qx.debug") && debugStack) {
let ex = null;
try {
throw new Error("getStack");
}catch(tmp) {
ex = tmp;
}
}
return new Promise((resolve, reject) => {
fn((err, ...args) => {
if (err) {
if (qx.core.Environment.get("qx.debug") && debugStack) {
console.log("Error: " + err + "\nCalled From: " + ex.stack);
}
reject(err);
} else {
resolve(...args);
Expand Down

0 comments on commit a438809

Please sign in to comment.