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

Side by Side Diff: remoting/webapp/crd/js/host_daemon_facade.js

Issue 1272833002: Pass error messages from native messaging to web-app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix start_host. Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class to communicate with the host daemon via Native Messaging. 7 * Class to communicate with the host daemon via Native Messaging.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 var reply = this.pendingReplies_[id]; 189 var reply = this.pendingReplies_[id];
190 if (!reply) { 190 if (!reply) {
191 console.error('NativeMessaging: unexpected id: ', id); 191 console.error('NativeMessaging: unexpected id: ', id);
192 return; 192 return;
193 } 193 }
194 delete this.pendingReplies_[id]; 194 delete this.pendingReplies_[id];
195 195
196 try { 196 try {
197 var type = base.getStringAttr(message, 'type'); 197 var type = base.getStringAttr(message, 'type');
198 if (type != reply.type) { 198 if (type != reply.type) {
199 throw 'Expected reply type: ' + reply.type + ', got: ' + type; 199 throw new Error('Expected reply type: ' + reply.type + ', got: ' + type);
200 }
201 var error_message = base.getStringAttr(message, 'error_message', '');
202 if (error_message) {
203 var error_location = base.getStringAttr(message, 'error_location',
204 '<unknown>')
205 console.error(error_message + ' at ' + error_location);
200 } 206 }
201 reply.deferred.resolve(message); 207 reply.deferred.resolve(message);
Sergey Ulanov 2015/08/06 22:40:57 should we call reject() in case there was an error
Jamie 2015/08/06 23:06:17 I don't think so. The contract here is that the ca
202 } catch (/** @type {*} */ e) { 208 } catch (/** @type {*} */ e) {
203 console.error('Error while processing native message', e); 209 console.error('Error while processing native message', e);
204 reply.deferred.reject(remoting.Error.unexpected()); 210 reply.deferred.reject(remoting.Error.unexpected());
205 } 211 }
206 }; 212 };
207 213
208 /** 214 /**
209 * @return {void} Nothing. 215 * @return {void} Nothing.
210 * @private 216 * @private
211 */ 217 */
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 authorizationCode: authorizationCode 484 authorizationCode: authorizationCode
479 }).then(function(reply) { 485 }).then(function(reply) {
480 var refreshToken = base.getStringAttr(reply, 'refreshToken'); 486 var refreshToken = base.getStringAttr(reply, 'refreshToken');
481 if (refreshToken) { 487 if (refreshToken) {
482 return refreshToken 488 return refreshToken
483 } else { 489 } else {
484 throw remoting.Error.unexpected('Missing refreshToken'); 490 throw remoting.Error.unexpected('Missing refreshToken');
485 } 491 }
486 }); 492 });
487 }; 493 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698