Tracebacks for async coroutines now provide a 'best guess' for where the coroutine was at the time that an exception was thrown, by showing the frame at which the generator's last continuation callback was created.

Added a 'location' property to RequestException, analogous to the 'location' property of wrapped nsIExceptions, so that tracebacks can be made for the exceptions if needed.
This commit is contained in:
Atul Varma 2008-07-01 11:12:00 -07:00
Родитель b3e8f8b8db
Коммит 3e0284ee03
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -115,6 +115,7 @@ function Generator(thisArg, method, onComplete, args) {
this._id = gCurrentId++; this._id = gCurrentId++;
this.onComplete = onComplete; this.onComplete = onComplete;
this._args = args; this._args = args;
this._stackAtLastCallbackGen = null;
gOutstandingGenerators.add(this); gOutstandingGenerators.add(this);
@ -132,6 +133,7 @@ Generator.prototype = {
let caller = Components.stack.caller; let caller = Components.stack.caller;
let cbId = gCurrentCbId++; let cbId = gCurrentCbId++;
this._outstandingCbs++; this._outstandingCbs++;
this._stackAtLastCallbackGen = caller;
this._log.trace(this.name + ": cb-" + cbId + " generated at:\n" + this._log.trace(this.name + ": cb-" + cbId + " generated at:\n" +
formatAsyncFrame(caller)); formatAsyncFrame(caller));
let self = this; let self = this;
@ -172,7 +174,11 @@ Generator.prototype = {
}, },
get asyncStack() { get asyncStack() {
return ("unknown (async) :: " + this.name + "\n" + let cbGenText = "";
if (this._stackAtLastCallbackGen)
cbGenText = (" (last self.cb generated at " +
formatAsyncFrame(this._stackAtLastCallbackGen) + ")");
return ("unknown (async) :: " + this.name + cbGenText + "\n" +
traceAsyncFrame(this._initFrame)); traceAsyncFrame(this._initFrame));
}, },

Просмотреть файл

@ -58,6 +58,7 @@ function RequestException(resource, action, request) {
this._resource = resource; this._resource = resource;
this._action = action; this._action = action;
this._request = request; this._request = request;
this.location = Components.stack.caller;
} }
RequestException.prototype = { RequestException.prototype = {
get resource() { return this._resource; }, get resource() { return this._resource; },