Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1042)

Unified Diff: remoting/webapp/background/it2me_helper_channel.js

Issue 547013002: It2MeHelperChannel error reporting cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/background/it2me_helper_channel.js
diff --git a/remoting/webapp/background/it2me_helper_channel.js b/remoting/webapp/background/it2me_helper_channel.js
index e039783273b6c462e57bc24fde01b1cc0f73b481..84608be60b576a47744dfaeb15e05b15a719a643 100644
--- a/remoting/webapp/background/it2me_helper_channel.js
+++ b/remoting/webapp/background/it2me_helper_channel.js
@@ -119,7 +119,8 @@ remoting.It2MeHelperChannel.HangoutMessageTypes = {
HELLO: 'hello',
HELLO_RESPONSE: 'helloResponse',
CONNECT: 'connect',
- DISCONNECT: 'disconnect'
+ DISCONNECT: 'disconnect',
+ ERROR: 'error'
};
/** @enum {string} */
@@ -167,11 +168,7 @@ remoting.It2MeHelperChannel.prototype.onHangoutMessage_ = function(message) {
throw new Error('Unknown message method=' + message.method);
} catch(e) {
var error = /** @type {Error} */ e;
- console.error(error);
- this.hangoutPort_.postMessage({
- method: message.method + 'Response',
- error: error.message
- });
+ this.sendErrorResponse_(this.hangoutPort_, error, message);
}
return false;
};
@@ -280,11 +277,7 @@ remoting.It2MeHelperChannel.prototype.onWebappMessage_ = function(message) {
throw new Error('Unknown message method=' + message.method);
} catch(e) {
var error = /** @type {Error} */ e;
- console.error(error);
- this.webappPort_.postMessage({
- method: message.method + 'Response',
- error: error.message
- });
+ this.sendErrorResponse_(this.webappPort_, error, message);
}
return false;
};
@@ -309,3 +302,25 @@ remoting.It2MeHelperChannel.prototype.unhookPorts_ = function() {
this.onDisconnectCallback_ = null;
}
};
+
+/**
+ * @param {chrome.runtime.Port} port
+ * @param {string|Error} error
+ * @param {?{method:string, data:Object.<string,*>}=} opt_incomingMessage
+ * @private
+ */
+remoting.It2MeHelperChannel.prototype.sendErrorResponse_ =
+ function(port, error, opt_incomingMessage) {
+ if (error instanceof Error) {
+ error = error.message;
+ }
+
+ console.error('Error responding to message method:' +
+ (opt_incomingMessage ? opt_incomingMessage.method : 'null') +
+ ' error:' + error);
+ port.postMessage({
+ method: remoting.It2MeHelperChannel.HangoutMessageTypes.ERROR,
+ message: error,
+ request: opt_incomingMessage
+ });
+};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698