mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
move formatAsyncFrame to utils, don't print 'regular' stack trace when we have an async exception (it's not useful)
This commit is contained in:
parent
0c474a106e
commit
94709c6381
@ -96,7 +96,7 @@ function AsyncException(asyncStack, exceptionToWrap) {
|
||||
|
||||
addAsyncFrame: function AsyncException_addAsyncFrame(frame) {
|
||||
this._asyncStack += ((this._asyncStack? "\n" : "") +
|
||||
formatAsyncFrame(frame));
|
||||
Utils.formatFrame(frame));
|
||||
},
|
||||
|
||||
toString: function AsyncException_toString() {
|
||||
@ -131,7 +131,7 @@ Generator.prototype = {
|
||||
this._outstandingCbs++;
|
||||
this._stackAtLastCallbackGen = caller;
|
||||
this._log.trace(this.name + ": cb-" + cbId + " generated at:\n" +
|
||||
formatAsyncFrame(caller));
|
||||
Utils.formatFrame(caller));
|
||||
let self = this;
|
||||
let cb = function(data) {
|
||||
self._log.trace(self.name + ": cb-" + cbId + " called.");
|
||||
@ -173,12 +173,12 @@ Generator.prototype = {
|
||||
let cbGenText = "";
|
||||
if (this._stackAtLastCallbackGen)
|
||||
cbGenText = (" (last self.cb generated at " +
|
||||
formatAsyncFrame(this._stackAtLastCallbackGen) + ")");
|
||||
Utils.formatFrame(this._stackAtLastCallbackGen) + ")");
|
||||
|
||||
let frame = skipAsyncFrames(this._initFrame);
|
||||
|
||||
return ("unknown (async) :: " + this.name + cbGenText + "\n" +
|
||||
Utils.stackTraceFromFrame(frame, formatAsyncFrame));
|
||||
Utils.stackTraceFromFrame(frame, Utils.formatFrame));
|
||||
},
|
||||
|
||||
_handleException: function AsyncGen__handleException(e) {
|
||||
@ -193,7 +193,7 @@ Generator.prototype = {
|
||||
if (e instanceof AsyncException) {
|
||||
// FIXME: attempt to skip repeated frames, which can happen if the
|
||||
// child generator never yielded. Would break for valid repeats (recursion)
|
||||
if (e.asyncStack.indexOf(formatAsyncFrame(this._initFrame)) == -1)
|
||||
if (e.asyncStack.indexOf(Utils.formatFrame(this._initFrame)) == -1)
|
||||
e.addAsyncFrame(this._initFrame);
|
||||
} else {
|
||||
e = new AsyncException(this.asyncStack, e);
|
||||
@ -205,7 +205,7 @@ Generator.prototype = {
|
||||
this._log.warn("Exception: " + Utils.exceptionStr(e));
|
||||
} else {
|
||||
this._log.error("Exception: " + Utils.exceptionStr(e));
|
||||
this._log.debug("Stack trace:\n" + Utils.stackTrace(e, formatAsyncFrame));
|
||||
this._log.debug("Async stack trace:\n" + Utils.stackTrace(e, Utils.formatFrame));
|
||||
}
|
||||
|
||||
// continue execution of caller.
|
||||
@ -301,7 +301,7 @@ Generator.prototype = {
|
||||
this.name + " generator");
|
||||
this._log.error("Exception: " + Utils.exceptionStr(e));
|
||||
this._log.trace("Current stack trace:\n" +
|
||||
Utils.stackTrace(e, formatAsyncFrame));
|
||||
Utils.stackTrace(e, Utils.formatFrame));
|
||||
this._log.trace("Initial async stack trace:\n" + this.asyncStack);
|
||||
}
|
||||
}
|
||||
@ -315,16 +315,6 @@ function skipAsyncFrames(frame) {
|
||||
return frame;
|
||||
}
|
||||
|
||||
function formatAsyncFrame(frame) {
|
||||
// FIXME: sort of hackish, might be confusing if there are multiple
|
||||
// extensions with similar filenames
|
||||
let tmp = "<file:unknown>";
|
||||
if (frame.filename)
|
||||
tmp = frame.filename.replace(/^file:\/\/.*\/([^\/]+.js)$/, "module:$1");
|
||||
tmp += ":" + frame.lineNumber + " :: " + frame.name;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Async = {
|
||||
get outstandingGenerators() { return gOutstandingGenerators; },
|
||||
|
||||
@ -359,5 +349,5 @@ Async = {
|
||||
let args = Array.prototype.slice.call(arguments, 1);
|
||||
args.unshift(thisArg, this);
|
||||
Async.run.apply(Async, args);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -230,12 +230,7 @@ WeaveSvc.prototype = {
|
||||
|
||||
_initialLoginAndSync: function Weave__initialLoginAndSync() {
|
||||
let self = yield;
|
||||
|
||||
// Any exceptions thrown by the login process will be propagated
|
||||
// out here, so there's no need to check to see if the login was
|
||||
// successful; if it wasn't, this coroutine will just abort.
|
||||
|
||||
yield this.login(self.cb);
|
||||
yield this.login(self.cb); // will throw if login fails
|
||||
yield this.sync(self.cb);
|
||||
},
|
||||
|
||||
@ -280,7 +275,7 @@ WeaveSvc.prototype = {
|
||||
this._log.info("Skipping scheduled sync; local operation in progress")
|
||||
} else {
|
||||
this._log.info("Running scheduled sync");
|
||||
this._notify("sync-as-needed", this._lock(this._syncAsNeeded)).async(this);
|
||||
this._notify("sync", this._lock(this._syncAsNeeded)).async(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -202,21 +202,35 @@ let Utils = {
|
||||
return ret;
|
||||
},
|
||||
|
||||
// Works on frames or exceptions, munges file:// URIs to shorten the paths
|
||||
// FIXME: filename munging is sort of hackish, might be confusing if
|
||||
// there are multiple extensions with similar filenames
|
||||
formatFrame: function Utils_formatFrame(frame) {
|
||||
let tmp = "<file:unknown>";
|
||||
if (frame.filename)
|
||||
tmp = frame.filename.replace(/^file:\/\/.*\/([^\/]+.js)$/, "module:$1");
|
||||
else if (frame.fileName)
|
||||
tmp = frame.fileName.replace(/^file:\/\/.*\/([^\/]+.js)$/, "module:$1");
|
||||
if (frame.lineNumber)
|
||||
tmp += ":" + frame.lineNumber;
|
||||
if (frame.name)
|
||||
tmp += " :: " + frame.name;
|
||||
return tmp;
|
||||
},
|
||||
|
||||
exceptionStr: function Weave_exceptionStr(e) {
|
||||
let message = e.message ? e.message : e;
|
||||
let location = "";
|
||||
|
||||
if (e.location)
|
||||
// It's a wrapped nsIException.
|
||||
if (e.location) // Wrapped nsIException.
|
||||
location = e.location;
|
||||
else if (e.fileName && e.lineNumber)
|
||||
// It's a standard JS exception.
|
||||
location = "file '" + e.fileName + "', line " + e.lineNumber;
|
||||
else if (e.fileName && e.lineNumber) // Standard JS exception
|
||||
location = Utils.formatFrame(e);
|
||||
|
||||
if (location)
|
||||
location = " (" + location + ")";
|
||||
return message + location;
|
||||
},
|
||||
},
|
||||
|
||||
stackTraceFromFrame: function Weave_stackTraceFromFrame(frame, formatter) {
|
||||
if (!formatter)
|
||||
@ -233,28 +247,14 @@ let Utils = {
|
||||
},
|
||||
|
||||
stackTrace: function Weave_stackTrace(e, formatter) {
|
||||
let output = "";
|
||||
if (e.location) {
|
||||
// It's a wrapped nsIException.
|
||||
output += this.stackTraceFromFrame(e.location, formatter);
|
||||
} else if (e.stack)
|
||||
// It's a standard JS exception.
|
||||
|
||||
// TODO: It would be nice if we could parse this string and
|
||||
// create a 'fake' nsIStackFrame-like call stack out of it,
|
||||
// so that we can do things w/ this stack trace like we do
|
||||
// with nsIException traces.
|
||||
output += e.stack;
|
||||
if (e.asyncStack) // AsyncException
|
||||
return e.asyncStack;
|
||||
else if (e.location) // Wrapped nsIException
|
||||
return this.stackTraceFromFrame(e.location, formatter);
|
||||
else if (e.stack) // Standard JS exception
|
||||
return e.stack;
|
||||
else
|
||||
// It's some other thrown object, e.g. a bare string.
|
||||
output += "No traceback available.\n";
|
||||
|
||||
if (e.asyncStack) {
|
||||
output += "This exception was raised by an asynchronous coroutine.\n";
|
||||
output += "Initial async stack trace:\n" + e.asyncStack;
|
||||
}
|
||||
|
||||
return output;
|
||||
return "No traceback available";
|
||||
},
|
||||
|
||||
checkStatus: function Weave_checkStatus(code, msg, ranges) {
|
||||
|
Loading…
Reference in New Issue
Block a user