Bug 889526 - Improve reportError so that it will add a stack trace if one is available; r=past

This commit is contained in:
Nick Fitzgerald 2013-07-03 14:10:52 -07:00
Родитель d4843c0cfc
Коммит eebeb27495
1 изменённых файлов: 12 добавлений и 13 удалений

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

@ -280,10 +280,7 @@ ThreadActor.prototype = {
resolve(onPacket(packet)).then(this.conn.send.bind(this.conn));
return this._nest();
} catch(e) {
let msg = "Got an exception during TA__pauseAndRespond: " + e +
": " + e.stack;
Cu.reportError(msg);
dumpn(msg);
reportError(e, "Got an exception during TA__pauseAndRespond: ");
return undefined;
}
},
@ -1241,8 +1238,7 @@ ThreadActor.prototype = {
this.conn.send(packet);
return this._nest();
} catch(e) {
Cu.reportError("Got an exception during TA_onExceptionUnwind: " + e +
": " + e.stack);
reportError(e, "Got an exception during TA_onExceptionUnwind: ");
return undefined;
}
},
@ -1490,10 +1486,7 @@ SourceActor.prototype = {
source: aSourceGrip
};
}, (aError) => {
let msg = "Got an exception during SA_onSource: " + aError +
"\n" + aError.stack;
Cu.reportError(msg);
dumpn(msg);
reportError(aError, "Got an exception during SA_onSource: ");
return {
"from": this.actorID,
"error": "loadSourceError",
@ -2924,8 +2917,14 @@ function convertToUnicode(aString, aCharset=null) {
/**
* Report the given error in the error console and to stdout.
*
* @param Error aError
* The error object you wish to report.
* @param String aPrefix
* An optional prefix for the reported error message.
*/
function reportError(aError) {
Cu.reportError(aError);
dumpn(aError.message + ":\n" + aError.stack);
function reportError(aError, aPrefix="") {
let msg = prefix + aError.message + ":\n" + aError.stack;
Cu.reportError(msg);
dumpn(msg);
}