1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 14:57:59 +01:00

Add some more error handling code during the bootstrapping process.

This commit is contained in:
Kris Maglione
2010-12-30 20:20:57 -05:00
parent 5f47d83f76
commit 85947d4645
5 changed files with 46 additions and 23 deletions

12
common/bootstrap.js vendored
View File

@@ -18,6 +18,11 @@ const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICa
const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
const storage = Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication).storage; const storage = Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication).storage;
function reportError(e) {
dump("dactyl: bootstrap: " + e + "\n" + (e.stack || Error().stack));
Cu.reportError(e);
}
function httpGet(url) { function httpGet(url) {
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
xmlhttp.open("GET", url, false); xmlhttp.open("GET", url, false);
@@ -93,10 +98,17 @@ FactoryProxy.prototype = {
manager.unregisterFactory(this.classID, this); manager.unregisterFactory(this.classID, this);
}, },
get module() { get module() {
try {
Object.defineProperty(this, "module", { value: {}, enumerable: true }); Object.defineProperty(this, "module", { value: {}, enumerable: true });
JSMLoader.load(this.url, this.module); JSMLoader.load(this.url, this.module);
JSMLoader.registerGlobal(this.url, this.module.global); JSMLoader.registerGlobal(this.url, this.module.global);
return this.module; return this.module;
}
catch (e) {
delete this.module;
reportError(e);
throw e;
}
}, },
createInstance: function (iids) { createInstance: function (iids) {
return let (factory = this.module.NSGetFactory(this.classID)) return let (factory = this.module.NSGetFactory(this.classID))

View File

@@ -4,6 +4,13 @@
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
"use strict"; "use strict";
function reportError(e) {
dump("dactyl: components: " + e + "\n" + (e.stack || Error().stack));
Cu.reportError(e);
}
try {
/* Adds support for data: URIs with chrome privileges /* Adds support for data: URIs with chrome privileges
* and fragment identifiers. * and fragment identifiers.
* *
@@ -216,4 +223,6 @@ else
var NSGetModule = XPCOMUtils.generateNSGetModule([AboutHandler, ChromeData, Dactyl, Shim]); var NSGetModule = XPCOMUtils.generateNSGetModule([AboutHandler, ChromeData, Dactyl, Shim]);
var EXPORTED_SYMBOLS = ["NSGetFactory", "global"]; var EXPORTED_SYMBOLS = ["NSGetFactory", "global"];
} catch (e) { reportError(e) }
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -2124,7 +2124,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
dactyl.commandLineOptions.noPlugins = "++noplugin" in args; dactyl.commandLineOptions.noPlugins = "++noplugin" in args;
dactyl.commandLineOptions.postCommands = args["+c"]; dactyl.commandLineOptions.postCommands = args["+c"];
dactyl.commandLineOptions.preCommands = args["++cmd"]; dactyl.commandLineOptions.preCommands = args["++cmd"];
util.dump("Processing command-line option: " + commandline); util.dump("Processing command-line option: " + args.string);
} }
} }
catch (e) { catch (e) {

View File

@@ -523,7 +523,7 @@ var Mappings = Module("mappings", {
for (let mode in values(modes.all)) for (let mode in values(modes.all))
if (name == mode || name == mode.char if (name == mode || name == mode.char
|| String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase()) || String.toLowerCase(name).replace(/-/g, "_") == mode.name.toLowerCase())
return mode.mask; return mode;
return null; return null;
} }
function uniqueModes(modes) { function uniqueModes(modes) {

View File

@@ -108,7 +108,7 @@ var Modes = Module("modes", {
hidden: true, hidden: true,
description: "Quote mode: The next key sequence is ignored by " + config.appName + ", unless in Pass Through mode", description: "Quote mode: The next key sequence is ignored by " + config.appName + ", unless in Pass Through mode",
display: function () modes.getStack(1).main == modes.PASS_THROUGH display: function () modes.getStack(1).main == modes.PASS_THROUGH
? (modes.getStack(2).mainMode.display() || modes.getStack(2).mainMode.name) + " (next)" ? (modes.getStack(2).main.display() || modes.getStack(2).mainMode.name) + " (next)"
: "PASS THROUGH (next)" : "PASS THROUGH (next)"
}, { }, {
// Fix me. // Fix me.
@@ -153,7 +153,7 @@ var Modes = Module("modes", {
prefs.set("accessibility.browsewithcaret", false); prefs.set("accessibility.browsewithcaret", false);
statusline.updateUrl(); statusline.updateUrl();
if (!stack.fromFocus && (prev.mainMode.input || prev.mainMode.ownsFocus)) if (!stack.fromFocus && (prev.main.input || prev.main.ownsFocus))
dactyl.focusContent(true); dactyl.focusContent(true);
if (prev.main == modes.NORMAL) { if (prev.main == modes.NORMAL) {
dactyl.focusContent(true); dactyl.focusContent(true);
@@ -369,18 +369,17 @@ var Modes = Module("modes", {
}, { }, {
Mode: Class("Mode", Number, { Mode: Class("Mode", Number, {
init: function init(name, options, params) { init: function init(name, options, params) {
let self = new Number(1 << Modes.Mode._id++);
update(this, { update(this, {
mask: self, id: 1 << Modes.Mode._id++,
name: name, name: name,
params: params || {} params: params || {}
}, options); }, options);
self.__proto__ = this;
return self;
}, },
toString: function () this.name, toString: function () this.name,
valueOf: function () this.id,
count: true, count: true,
get description() this.disp, get description() this.disp,
@@ -393,21 +392,24 @@ var Modes = Module("modes", {
hidden: false, hidden: false,
input: false input: false,
get mask() this
}, { }, {
_id: 0 _id: 0
}), }),
StackElement: (function () { StackElement: (function () {
let struct = Struct("main", "extended", "params", "saved"); const StackElement = Struct("main", "extended", "params", "saved");
struct.defaultValue("params", function () this.main.params); StackElement.defaultValue("params", function () this.main.params);
struct.prototype.__defineGetter__("mainMode", function () modes.getMode(this.main)); update(StackElement.prototype, {
struct.prototype.toString = function () !loaded.modes ? this.main : "[mode " + toString: function () !loaded.modes ? this.main : "[mode " +
this.mainMode.name + this.main.name +
(!this.extended ? "" : (!this.extended ? "" :
"(" + "(" + modes.all.filter(function (m) this.extended & m)
[modes.getMode(1 << i).name for (i in util.range(0, 32)) if (modes.getMode(1 << i) && (this.extended & (1 << i)))].join("|") + .join("|") +
")") + "]"; ")") + "]"
return struct; });
return StackElement;
})(), })(),
cacheId: 0, cacheId: 0,
boundProperty: function boundProperty(desc) { boundProperty: function boundProperty(desc) {