我正在为Firefox构建自举扩展(由于需要tcp套接字,所以不使用附加SDK)。尽管我所有的IO调用等都受到try / catch的保护,但我还是希望有一个全局错误处理程序,以防万一。自举扩展不能访问window对象,因此window.onerror路由是不可能的。关于如何解决这个问题有什么建议吗?
提前致谢。
没有可靠的全局错误处理程序。只需将startup
/ shutdown
(install
/ uninstall
)换行try-catch
。您可能还需要包装全局语句。
try {
// do some fancy initialization... But you really shouldn't at the global scope.
}
catch (ex) {
// handle/log error, e.g.
Components.utils.reportError(ex);
}
function startup() {
try {
// Run
}
catch (ex) {
// handle/log error, e.g.
Components.utils.reportError(ex);
}
}
function shutdown() …
// etc.
扩展管理器仍然会使用bootstrap.js记录故障(请参阅extensions.logging.enabled
首选项)。
另外:SDK附加组件可以使用该chrome
模块来访问低级内容。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句