Index: remoting/webapp/crd/js/it2me_helpee_channel.js |
diff --git a/remoting/webapp/crd/js/it2me_helpee_channel.js b/remoting/webapp/crd/js/it2me_helpee_channel.js |
index 79c016b3dd7fc3375f27428e2213b78e3b1c0293..71a849e22de562bfe4c5f53fb2d7a1944633d916 100644 |
--- a/remoting/webapp/crd/js/it2me_helpee_channel.js |
+++ b/remoting/webapp/crd/js/it2me_helpee_channel.js |
@@ -188,8 +188,8 @@ remoting.It2MeHelpeeChannel.prototype.onHangoutMessage_ = function(message) { |
return true; |
} |
throw new Error('Unsupported message method=' + message.method); |
- } catch(/** @type {Error} */ error) { |
- this.sendErrorResponse_(message, error.message); |
+ } catch(/** @type {!Error} */ error) { |
+ this.sendErrorResponse_(message, error); |
} |
return false; |
}; |
@@ -227,9 +227,8 @@ remoting.It2MeHelpeeChannel.prototype.handleIsHostInstalled_ = |
remoting.It2MeHelpeeChannel.prototype.handleDownloadHost_ = function(message) { |
try { |
this.hostInstaller_.download(); |
- } catch (/** @type {*} */ e) { |
- var error = /** @type {Error} */ (e); |
- this.sendErrorResponse_(message, error.message); |
+ } catch (/** @type {!Error} */ error) { |
+ this.sendErrorResponse_(message, error); |
} |
}; |
@@ -264,9 +263,8 @@ remoting.It2MeHelpeeChannel.prototype.handleConnect_ = |
/** @param {{email:string, token:string}|Promise} result */ |
.then(function(result) { |
that.connectToHost_(result.email, result.token); |
- /** @param {*} reason */ |
- }).catch(function(reason) { |
- that.sendErrorResponse_(message, /** @type {Error} */ (reason)); |
+ }).catch(function(/** !Error */ reason) { |
Jamie
2015/03/02 18:28:10
Missing @type?
Also, I thought we had problems wi
John Williams
2015/03/02 22:01:37
Yeah, it's fixed now, and the abbreviates type syn
|
+ that.sendErrorResponse_(message, reason); |
that.dispose(); |
}); |
}; |
@@ -308,7 +306,7 @@ remoting.It2MeHelpeeChannel.prototype.showConfirmDialogV1_ = function() { |
if(window.confirm(message)) { |
return Promise.resolve(); |
} else { |
- return Promise.reject(new Error(remoting.Error.CANCELLED)); |
+ return Promise.reject(remoting.Error.CANCELLED); |
} |
}; |
@@ -362,14 +360,16 @@ remoting.It2MeHelpeeChannel.prototype.fetchOAuthToken_ = function() { |
return remoting.identity.getToken(); |
} else { |
var onError = function(/** * */ error) { |
- if (error === remoting.Error.NOT_AUTHENTICATED) { |
+ if (error instanceof remoting.Error && |
+ /** @type {!remoting.Error} */ (error).tag === |
+ remoting.Error.Tag.NOT_AUTHENTICATED) { |
return new Promise(function(resolve, reject) { |
remoting.oauth2.doAuthRedirect(function() { |
remoting.identity.getToken().then(resolve); |
}); |
}); |
} |
- throw Error(remoting.Error.NOT_AUTHENTICATED); |
+ throw remoting.Error.NOT_AUTHENTICATED; |
}; |
return /** @type {!Promise<string>} */ ( |
remoting.identity.getToken().catch(onError)); |
@@ -413,7 +413,7 @@ remoting.It2MeHelpeeChannel.prototype.connectToHost_ = |
}; |
/** |
- * @param {remoting.Error} error |
+ * @param {!remoting.Error} error |
* @private |
*/ |
remoting.It2MeHelpeeChannel.prototype.onHostConnectError_ = function(error) { |
@@ -457,21 +457,26 @@ remoting.It2MeHelpeeChannel.prototype.onHostStateChanged_ = function(state) { |
/** |
* @param {?{method:string, data:Object<string,*>}} incomingMessage |
- * @param {string|Error} error |
+ * @param {!remoting.Error|!Error} error |
* @private |
*/ |
remoting.It2MeHelpeeChannel.prototype.sendErrorResponse_ = |
function(incomingMessage, error) { |
+ /** @type {string} */ |
+ var errorMessage; |
+ |
if (error instanceof Error) { |
- error = error.message; |
+ errorMessage = error.message; |
+ } else { |
+ errorMessage = error.tag; |
} |
console.error('Error responding to message method:' + |
(incomingMessage ? incomingMessage.method : 'null') + |
- ' error:' + error); |
+ ' error:' + errorMessage); |
this.hangoutPort_.postMessage({ |
method: remoting.It2MeHelpeeChannel.HangoutMessageTypes.ERROR, |
- message: error, |
+ message: errorMessage, |
request: incomingMessage |
}); |
}; |