mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out b4913818b95e (bug 878319) for browser-chrome bustage
CLOSED TREE
This commit is contained in:
parent
a940543ba1
commit
2ecb698245
@ -1,80 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* General utilities used throughout devtools. */
|
||||
|
||||
this.EXPORTED_SYMBOLS = [ "DevToolsUtils" ];
|
||||
|
||||
var Cu = Components.utils;
|
||||
|
||||
/* Turn the error e into a string, without fail. */
|
||||
function safeErrorString(aError) {
|
||||
try {
|
||||
var s = aError.toString();
|
||||
if (typeof s === "string")
|
||||
return s;
|
||||
} catch (ee) { }
|
||||
|
||||
return "<failed trying to find error description>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Report that |aWho| threw an exception, |aException|.
|
||||
*/
|
||||
function reportException(aWho, aException) {
|
||||
let msg = aWho + " threw an exception: " + safeErrorString(aException);
|
||||
if (aException.stack) {
|
||||
msg += "\nCall stack:\n" + aException.stack;
|
||||
}
|
||||
|
||||
dump(msg + "\n");
|
||||
|
||||
if (Cu.reportError) {
|
||||
/*
|
||||
* Note that the xpcshell test harness registers an observer for
|
||||
* console messages, so when we're running tests, this will cause
|
||||
* the test to quit.
|
||||
*/
|
||||
Cu.reportError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a handler function that may throw, return an infallible handler
|
||||
* function that calls the fallible handler, and logs any exceptions it
|
||||
* throws.
|
||||
*
|
||||
* @param aHandler function
|
||||
* A handler function, which may throw.
|
||||
* @param aName string
|
||||
* A name for aHandler, for use in error messages. If omitted, we use
|
||||
* aHandler.name.
|
||||
*
|
||||
* (SpiderMonkey does generate good names for anonymous functions, but we
|
||||
* don't have a way to get at them from JavaScript at the moment.)
|
||||
*/
|
||||
function makeInfallible(aHandler, aName) {
|
||||
if (!aName)
|
||||
aName = aHandler.name;
|
||||
|
||||
return function (/* arguments */) {
|
||||
try {
|
||||
return aHandler.apply(this, arguments);
|
||||
} catch (ex) {
|
||||
let who = "Handler function";
|
||||
if (aName) {
|
||||
who += " " + aName;
|
||||
}
|
||||
reportException(who, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.DevToolsUtils = {
|
||||
safeErrorString: safeErrorString,
|
||||
reportException: reportException,
|
||||
makeInfallible: makeInfallible
|
||||
};
|
@ -3,9 +3,6 @@
|
||||
|
||||
Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/DevToolsUtils.jsm");
|
||||
|
||||
var { safeErrorString } = DevToolsUtils;
|
||||
|
||||
let port = 2929;
|
||||
|
||||
|
@ -7,8 +7,61 @@
|
||||
"use strict";
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
Components.utils.import("resource://gre/modules/devtools/DevToolsUtils.jsm");
|
||||
var { makeInfallible } = DevToolsUtils;
|
||||
/* Turn the error e into a string, without fail. */
|
||||
function safeErrorString(aError) {
|
||||
try {
|
||||
var s = aError.toString();
|
||||
if (typeof s === "string")
|
||||
return s;
|
||||
} catch (ee) { }
|
||||
|
||||
return "<failed trying to find error description>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a handler function that may throw, return an infallible handler
|
||||
* function that calls the fallible handler, and logs any exceptions it
|
||||
* throws.
|
||||
*
|
||||
* @param aHandler function
|
||||
* A handler function, which may throw.
|
||||
* @param aName string
|
||||
* A name for aHandler, for use in error messages. If omitted, we use
|
||||
* aHandler.name.
|
||||
*
|
||||
* (SpiderMonkey does generate good names for anonymous functions, but we
|
||||
* don't have a way to get at them from JavaScript at the moment.)
|
||||
*/
|
||||
function makeInfallible(aHandler, aName) {
|
||||
if (!aName)
|
||||
aName = aHandler.name;
|
||||
|
||||
return function (/* arguments */) {
|
||||
try {
|
||||
return aHandler.apply(this, arguments);
|
||||
} catch (ex) {
|
||||
let msg = "Handler function ";
|
||||
if (aName) {
|
||||
msg += aName + " ";
|
||||
}
|
||||
msg += "threw an exception: " + safeErrorString(ex);
|
||||
if (ex.stack) {
|
||||
msg += "\nCall stack:\n" + ex.stack;
|
||||
}
|
||||
|
||||
dump(msg + "\n");
|
||||
|
||||
if (Cu.reportError) {
|
||||
/*
|
||||
* Note that the xpcshell test harness registers an observer for
|
||||
* console messages, so when we're running tests, this will cause
|
||||
* the test to quit.
|
||||
*/
|
||||
Cu.reportError(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An adapter that handles data transfers between the debugger client and
|
||||
|
Loading…
Reference in New Issue
Block a user