| 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
|
| + });
|
| +};
|
|
|