mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
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:
parent
e31b715a96
commit
b355e57a31
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user