зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1093387 - Better WebIDE runtime error handling. r=ochameau
This commit is contained in:
Родитель
409f9f0f5d
Коммит
3a4f8e047f
|
@ -292,7 +292,7 @@ let UI = {
|
|||
this.unbusy();
|
||||
}, (e) => {
|
||||
let message;
|
||||
if (e.error && e.message) {
|
||||
if (e && e.error && e.message) {
|
||||
// Some errors come from fronts that are not based on protocol.js.
|
||||
// Errors are not translated to strings.
|
||||
message = operationDescription + " (" + e.error + "): " + e.message;
|
||||
|
@ -303,7 +303,9 @@ let UI = {
|
|||
let operationCanceled = e && e.canceled;
|
||||
if (!operationCanceled) {
|
||||
UI.reportError("error_operationFail", message);
|
||||
console.error(e);
|
||||
if (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
this.unbusy();
|
||||
});
|
||||
|
@ -439,8 +441,13 @@ let UI = {
|
|||
connectToRuntime: function(runtime) {
|
||||
let name = runtime.name;
|
||||
let promise = AppManager.connectToRuntime(runtime);
|
||||
promise.then(() => this.initConnectionTelemetry());
|
||||
return this.busyUntil(promise, "connecting to runtime " + name);
|
||||
promise.then(() => this.initConnectionTelemetry())
|
||||
.catch(() => {
|
||||
// Empty rejection handler to silence uncaught rejection warnings
|
||||
// |busyUntil| will listen for rejections.
|
||||
// Bug 1121100 may find a better way to silence these.
|
||||
});
|
||||
return this.busyUntil(promise, "Connecting to " + name);
|
||||
},
|
||||
|
||||
updateRuntimeButton: function() {
|
||||
|
|
|
@ -93,12 +93,13 @@ let AppManager = exports.AppManager = {
|
|||
},
|
||||
|
||||
onConnectionChanged: function() {
|
||||
console.log("Connection status changed: " + this.connection.status);
|
||||
|
||||
if (this.connection.status == Connection.Status.DISCONNECTED) {
|
||||
this.selectedRuntime = null;
|
||||
}
|
||||
|
||||
if (this.connection.status != Connection.Status.CONNECTED) {
|
||||
console.log("Connection status changed: " + this.connection.status);
|
||||
if (this._appsFront) {
|
||||
this._appsFront.off("install-progress", this.onInstallProgress);
|
||||
this._appsFront.unwatchApps();
|
||||
|
@ -354,18 +355,15 @@ let AppManager = exports.AppManager = {
|
|||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.connection.on(Connection.Events.CONNECTED, onConnectedOrDisconnected);
|
||||
this.connection.on(Connection.Events.DISCONNECTED, onConnectedOrDisconnected);
|
||||
try {
|
||||
// Reset the connection's state to defaults
|
||||
this.connection.resetOptions();
|
||||
this.selectedRuntime.connect(this.connection).then(
|
||||
() => {},
|
||||
deferred.reject.bind(deferred));
|
||||
deferred.resolve(this.selectedRuntime.connect(this.connection));
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
deferred.reject();
|
||||
deferred.reject(e);
|
||||
}
|
||||
}, deferred.reject);
|
||||
|
||||
|
@ -386,6 +384,10 @@ let AppManager = exports.AppManager = {
|
|||
this.connection.once(Connection.Events.STATUS_CHANGED, () => {
|
||||
this._telemetry.stopTimer(timerId);
|
||||
});
|
||||
}).catch(() => {
|
||||
// Empty rejection handler to silence uncaught rejection warnings
|
||||
// |connectToRuntime| caller should listen for rejections.
|
||||
// Bug 1121100 may find a better way to silence these.
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
|
|
|
@ -401,7 +401,7 @@ DeprecatedUSBRuntime.prototype = {
|
|||
},
|
||||
connect: function(connection) {
|
||||
if (!this.device) {
|
||||
return promise.reject("Can't find device: " + this.name);
|
||||
return promise.reject(new Error("Can't find device: " + this.name));
|
||||
}
|
||||
return this.device.connect().then((port) => {
|
||||
connection.host = "localhost";
|
||||
|
@ -445,7 +445,7 @@ WiFiRuntime.prototype = {
|
|||
connect: function(connection) {
|
||||
let service = discovery.getRemoteService("devtools", this.deviceName);
|
||||
if (!service) {
|
||||
return promise.reject("Can't find device: " + this.name);
|
||||
return promise.reject(new Error("Can't find device: " + this.name));
|
||||
}
|
||||
connection.host = service.host;
|
||||
connection.port = service.port;
|
||||
|
@ -474,7 +474,7 @@ SimulatorRuntime.prototype = {
|
|||
let port = ConnectionManager.getFreeTCPPort();
|
||||
let simulator = Simulator.getByName(this.name);
|
||||
if (!simulator || !simulator.launch) {
|
||||
return promise.reject("Can't find simulator: " + this.name);
|
||||
return promise.reject(new Error("Can't find simulator: " + this.name));
|
||||
}
|
||||
return simulator.launch({port: port}).then(() => {
|
||||
connection.host = "localhost";
|
||||
|
@ -520,7 +520,7 @@ let gRemoteRuntime = {
|
|||
connect: function(connection) {
|
||||
let win = Services.wm.getMostRecentWindow("devtools:webide");
|
||||
if (!win) {
|
||||
return promise.reject();
|
||||
return promise.reject(new Error("No WebIDE window found"));
|
||||
}
|
||||
let ret = {value: connection.host + ":" + connection.port};
|
||||
let title = Strings.GetStringFromName("remote_runtime_promptTitle");
|
||||
|
@ -531,7 +531,7 @@ let gRemoteRuntime = {
|
|||
return promise.reject({canceled: true});
|
||||
}
|
||||
if (!host || !port) {
|
||||
return promise.reject();
|
||||
return promise.reject(new Error("Invalid host or port"));
|
||||
}
|
||||
connection.host = host;
|
||||
connection.port = port;
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
|
||||
function connectToRuntime(win, type, index) {
|
||||
return Task.spawn(function*() {
|
||||
yield startConnection(win, type, index);
|
||||
startConnection(win, type, index);
|
||||
yield waitUntilConnected(win);
|
||||
});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче