forked from mirrors/gecko-dev
Bug 1873150 - [devtools] Throw in getPreview if evaluated expression has syntax error. r=ochameau,devtools-reviewers.
This will allow us to be notified about expression we shouldn't try to evaluate. Differential Revision: https://phabricator.services.mozilla.com/D197762
This commit is contained in:
parent
2a19dc7c63
commit
00403eb75e
1 changed files with 14 additions and 3 deletions
|
|
@ -82,9 +82,20 @@ export function getPreview(target, tokenPos, editor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { result } = await client.evaluate(expression, {
|
const { result, hasException, exception } = await client.evaluate(
|
||||||
frameId: selectedFrame.id,
|
expression,
|
||||||
});
|
{
|
||||||
|
frameId: selectedFrame.id,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// The evaluation shouldn't return an exception.
|
||||||
|
if (hasException) {
|
||||||
|
const errorClass = exception?.getGrip()?.class || "Error";
|
||||||
|
throw new Error(
|
||||||
|
`Debugger internal exception: Preview for <${expression}> threw a ${errorClass}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const resultGrip = getGrip(result);
|
const resultGrip = getGrip(result);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue