mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-17 18:25:47 +01:00
Finish moving dactyl.dump to util from last commit, and store the last 15 intercepted stack traces.
This commit is contained in:
@@ -137,7 +137,10 @@ function require(obj, name, from) {
|
||||
}
|
||||
catch (e) {
|
||||
dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n");
|
||||
dump(" " + e.fileName + ":" + e.lineNumber + ": " + e +"\n");
|
||||
if (loaded.util)
|
||||
util.reportError(e);
|
||||
else
|
||||
dump(" " + e.fileName + ":" + e.lineNumber + ": " + e +"\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +154,7 @@ defineModule("base", {
|
||||
"isObject", "isString", "isSubclass", "iter", "iterAll", "keys",
|
||||
"memoize", "properties", "requiresMainThread", "set", "update", "values"
|
||||
],
|
||||
use: ["services"]
|
||||
use: ["services", "util"]
|
||||
});
|
||||
|
||||
function Runnable(self, func, args) {
|
||||
@@ -697,12 +700,7 @@ Class.Property.prototype.init = function () {};
|
||||
Class.extend = function extend(subclass, superclass, overrides) {
|
||||
subclass.superclass = superclass;
|
||||
|
||||
try {
|
||||
subclass.prototype = Object.create(superclass.prototype);
|
||||
}
|
||||
catch(e) {
|
||||
dump(e + "\n" + String.replace(e.stack, /^/gm, " ") + "\n\n");
|
||||
}
|
||||
subclass.prototype = Object.create(superclass.prototype);
|
||||
update(subclass.prototype, overrides);
|
||||
subclass.prototype.constructor = subclass;
|
||||
subclass.prototype._class_ = subclass;
|
||||
|
||||
@@ -153,7 +153,8 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
catch (e) {
|
||||
errors = errors || {};
|
||||
errors[itemName] = e;
|
||||
dump("Error sanitizing " + itemName + ": " + e + "\n" + e.stack + "\n");
|
||||
util.dump("Error sanitizing " + itemName);
|
||||
util.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +173,8 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
||||
catch (e) {
|
||||
errors = errors || {};
|
||||
errors[itemName] = e;
|
||||
dump("Error sanitizing " + itemName + ": " + e + "\n" + e.stack + "\n");
|
||||
util.dump("Error sanitizing " + itemName);
|
||||
util.reportError(e);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
defineModule("services", {
|
||||
exports: ["Services", "services"]
|
||||
exports: ["Services", "services"],
|
||||
use: ["util"]
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -72,7 +73,7 @@ const Services = Module("Services", {
|
||||
}
|
||||
catch (e) {
|
||||
// dactyl.log() is not defined at this time, so just dump any error
|
||||
dump("Service creation failed for '" + classes + "': " + e + "\n");
|
||||
util.dump("Service creation failed for '" + classes + "': " + e + "\n");
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -299,7 +299,7 @@ const File = Class("File", {
|
||||
file.initWithPath(expandedPath);
|
||||
}
|
||||
catch (e) {
|
||||
dump("dactyl: " + e + "\n" + String.replace(e.stack, /^/gm, "dactyl: ") + "\n");
|
||||
util.reportError(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ const Util = Module("Util", {
|
||||
if (observers[target])
|
||||
observers[target].call(obj, subject, data);
|
||||
});
|
||||
this.dactyl.dump(String(obj), obj instanceof Ci.nsIObserver);
|
||||
register("addObserver");
|
||||
},
|
||||
|
||||
@@ -230,9 +229,6 @@ const Util = Module("Util", {
|
||||
* Prints a message to the console. If <b>msg</b> is an object it is
|
||||
* pretty printed.
|
||||
*
|
||||
* NOTE: the "browser.dom.window.dump.enabled" preference needs to be
|
||||
* set.
|
||||
*
|
||||
* @param {string|Object} msg The message to print.
|
||||
*/
|
||||
dump: function dump_() {
|
||||
@@ -676,6 +672,8 @@ const Util = Module("Util", {
|
||||
}
|
||||
},
|
||||
|
||||
maxErrors: 15,
|
||||
errors: Class.memoize(function () []),
|
||||
reportError: function (error) {
|
||||
if (Cu.reportError)
|
||||
Cu.reportError(error);
|
||||
@@ -686,16 +684,16 @@ const Util = Module("Util", {
|
||||
stack: <>{String.replace(error.stack || Error().stack, /^/mg, "\t")}</>
|
||||
});
|
||||
|
||||
let errors = storage.newArray("errors", { store: false });
|
||||
errors.toString = function () [String(v[0]) + "\n" + v[1] for ([k, v] in this)].join("\n\n");
|
||||
errors.push([new Date, obj + obj.stack]);
|
||||
this.errors.push([new Date, obj + "\n" + obj.stack]);
|
||||
this.errors = this.errors.slice(-this.maxErrors);
|
||||
this.errors.toString = function () [k + "\n" + v for ([k, v] in array.iterValues(this))].join("\n\n");
|
||||
|
||||
util.dump(String(error));
|
||||
util.dump(obj);
|
||||
util.dump("");
|
||||
this.dump(String(error));
|
||||
this.dump(obj);
|
||||
this.dump("");
|
||||
}
|
||||
catch (e) {
|
||||
dump(e);
|
||||
this.dump(e);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user