OLD | NEW |
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 Loading... |
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); |
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. |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 }; |
OLD | NEW |