зеркало из https://github.com/mozilla/gecko-dev.git
Bug 506302 - Shorten stack traces
Trim the full path from JS stacks and just show the file and convert nsIException traces to look like js stacks: func()@file:line. Only difference is js stacks show arguments while nsIException always shows just (). Fix up some places where we print the exception instead of the fixed up string.
This commit is contained in:
Родитель
afca7c787c
Коммит
0658441e64
|
@ -154,7 +154,7 @@ RecordManager.prototype = {
|
||||||
return this.set(url, record);
|
return this.set(url, record);
|
||||||
}
|
}
|
||||||
catch(ex) {
|
catch(ex) {
|
||||||
this._log.debug("Failed to import record: " + ex);
|
this._log.debug("Failed to import record: " + Utils.exceptionStr(ex));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -64,7 +64,7 @@ FTService.prototype = {
|
||||||
|
|
||||||
onException: function FTS_onException(ex) {
|
onException: function FTS_onException(ex) {
|
||||||
this._lastException = ex;
|
this._lastException = ex;
|
||||||
this._log.debug(Utils.exceptionStr(ex) + " " + Utils.stackTrace(ex));
|
this._log.debug(Utils.exceptionStr(ex));
|
||||||
return true; // continue sync if thrown by a sync engine
|
return true; // continue sync if thrown by a sync engine
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -65,8 +65,7 @@ let Utils = {
|
||||||
return func.call(thisArg);
|
return func.call(thisArg);
|
||||||
}
|
}
|
||||||
catch(ex) {
|
catch(ex) {
|
||||||
thisArg._log.debug(["Caught exception:", Utils.exceptionStr(ex),
|
thisArg._log.debug("Exception: " + Utils.exceptionStr(ex));
|
||||||
Utils.stackTrace(ex)].join(" ").replace(/\n/g, " "));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -349,56 +348,45 @@ let Utils = {
|
||||||
formatFrame: function Utils_formatFrame(frame) {
|
formatFrame: function Utils_formatFrame(frame) {
|
||||||
let tmp = "<file:unknown>";
|
let tmp = "<file:unknown>";
|
||||||
|
|
||||||
if (frame.filename)
|
let file = frame.filename || frame.fileName;
|
||||||
tmp = frame.filename.replace(/^file:\/\/.*\/([^\/]+.js)$/, "module:$1");
|
if (file)
|
||||||
else if (frame.fileName)
|
tmp = file.replace(/^(?:chrome|file):.*?([^\/\.]+\.\w+)$/, "$1");
|
||||||
tmp = frame.fileName.replace(/^file:\/\/.*\/([^\/]+.js)$/, "module:$1");
|
|
||||||
|
|
||||||
if (frame.lineNumber)
|
if (frame.lineNumber)
|
||||||
tmp += ":" + frame.lineNumber;
|
tmp += ":" + frame.lineNumber;
|
||||||
if (frame.name)
|
if (frame.name)
|
||||||
tmp += " :: " + frame.name;
|
tmp = frame.name + "()@" + tmp;
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
},
|
},
|
||||||
|
|
||||||
exceptionStr: function Weave_exceptionStr(e) {
|
exceptionStr: function Weave_exceptionStr(e) {
|
||||||
let message = e.message ? e.message : e;
|
let message = e.message ? e.message : e;
|
||||||
let location = "";
|
return message + " " + Utils.stackTrace(e);
|
||||||
|
|
||||||
if (e.location) // Wrapped nsIException.
|
|
||||||
location = e.location;
|
|
||||||
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) {
|
stackTraceFromFrame: function Weave_stackTraceFromFrame(frame) {
|
||||||
if (!formatter)
|
let output = [];
|
||||||
formatter = function defaultFormatter(frame) { return frame; };
|
|
||||||
|
|
||||||
let output = "";
|
|
||||||
|
|
||||||
while (frame) {
|
while (frame) {
|
||||||
let str = formatter(frame);
|
let str = Utils.formatFrame(frame);
|
||||||
if (str)
|
if (str)
|
||||||
output += str + "\n";
|
output.push(str);
|
||||||
frame = frame.caller;
|
frame = frame.caller;
|
||||||
}
|
}
|
||||||
|
return output.join(" < ");
|
||||||
return output;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
stackTrace: function Weave_stackTrace(e, formatter) {
|
stackTrace: function Weave_stackTrace(e) {
|
||||||
if (e.location) // Wrapped nsIException
|
// Wrapped nsIException
|
||||||
return "Stack trace:\n" + this.stackTraceFromFrame(e.location, formatter);
|
if (e.location)
|
||||||
else if (e.stack) // Standard JS exception
|
return "Stack trace: " + Utils.stackTraceFromFrame(e.location);
|
||||||
return "JS Stack trace:\n" + e.stack;
|
|
||||||
else
|
// Standard JS exception
|
||||||
return "No traceback available";
|
if (e.stack)
|
||||||
|
return "JS Stack trace: " + e.stack.trim().replace(/\n/g, " < ").
|
||||||
|
replace(/@(?:chrome|file):.*?([^\/\.]+\.\w+:)/g, "@$1");
|
||||||
|
|
||||||
|
return "No traceback available";
|
||||||
},
|
},
|
||||||
|
|
||||||
checkStatus: function Weave_checkStatus(code, msg, ranges) {
|
checkStatus: function Weave_checkStatus(code, msg, ranges) {
|
||||||
|
@ -456,7 +444,7 @@ let Utils = {
|
||||||
return Svc.IO.newURI(URIString, null, null);
|
return Svc.IO.newURI(URIString, null, null);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let log = Log4Moz.repository.getLogger("Service.Util");
|
let log = Log4Moz.repository.getLogger("Service.Util");
|
||||||
log.debug("Could not create URI: " + e);
|
log.debug("Could not create URI: " + Utils.exceptionStr(e));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -518,7 +506,7 @@ let Utils = {
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
if (that._log)
|
if (that._log)
|
||||||
that._log.debug("Failed to load json: " + ex);
|
that._log.debug("Failed to load json: " + Utils.exceptionStr(ex));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче