Skip to content

Commit

Permalink
Remove handleRawError call from extension connection (#1697)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored and paulirish committed Feb 15, 2017
1 parent 3043cc3 commit e314396
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion lighthouse-core/gather/connections/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ class Connection {
const callback = this._callbacks.get(object.id);
this._callbacks.delete(object.id);

// handleRawError returns or throws synchronously; wrap to put into promise chain.
return callback.resolve(Promise.resolve().then(_ => {
if (object.error) {
log.formatProtocol('method <= browser ERR', {method: callback.method}, 'error');
Expand Down
14 changes: 5 additions & 9 deletions lighthouse-core/gather/connections/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,14 @@ class ExtensionConnection extends Connection {
// The error from the extension has a `message` property that is the
// stringified version of the actual protocol error object.
const message = chrome.runtime.lastError.message;
let error;
let errorMessage;
try {
error = JSON.parse(message);
errorMessage = JSON.parse(message).message;
} catch (e) {}
error = error || {message: 'Unknown debugger protocol error.'};
errorMessage = errorMessage || 'Unknown debugger protocol error.';

// handleRawError returns or throws synchronously, so try/catch awkwardly.
try {
return resolve(this.handleRawError(error, command));
} catch (err) {
return reject(err);
}
log.formatProtocol('method <= browser ERR', {method: command}, 'error');
return reject(new Error(`Protocol error (${command}): ${errorMessage}`));
}

log.formatProtocol('method <= browser OK', {method: command, params: result}, 'verbose');
Expand Down

0 comments on commit e314396

Please sign in to comment.