Bug 1548098 - Pull out exception handling into a dedicated _returnError method. r=remote-protocol-reviewers,ato

This will be used in the next changeset.

Differential Revision: https://phabricator.services.mozilla.com/D30263

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2019-05-13 16:10:43 +00:00
Родитель e31b715a96
Коммит b355e57a31
1 изменённых файлов: 25 добавлений и 12 удалений

Просмотреть файл

@ -59,24 +59,37 @@ class ExecutionContext {
};
}
if (rv.throw) {
if (this._debuggee.executeInGlobalWithBindings("e instanceof Error", {e: rv.throw}).return) {
return {
exceptionDetails: {
text: this._debuggee.executeInGlobalWithBindings("e.message", {e: rv.throw}).return,
},
};
}
return {
exceptionDetails: {
exception: this._createRemoteObject(rv.throw),
},
};
return this._returnError(rv.throw);
}
return {
result: this._createRemoteObject(rv.return),
};
}
/**
* Given a Debugger.Object reference for an Exception, return a JSON object
* describing the exception by following CDP ExceptionDetails specification.
*/
_returnError(exception) {
if (this._debuggee.executeInGlobalWithBindings("exception instanceof Error",
{exception}).return) {
const text = this._debuggee.executeInGlobalWithBindings("exception.message",
{exception}).return;
return {
exceptionDetails: {
text,
},
};
}
// If that isn't an Error, consider the exception as a JS value
return {
exceptionDetails: {
exception: this._toRemoteObject(exception),
},
};
}
/**
* Convert a given `Debugger.Object` to a JSON string.
*