Skip to content

Commit

Permalink
Render Error objects in CDT (#45990)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #45990

X-link: facebook/hermes#1471

Changelog:
[General][Added]: support for rendering Error objects in Chrome DevTools console

As discussed in [Linkifying and symbolicating JavaScript Error stacks in Fusebox](https://docs.google.com/document/d/1JI_PPzxFRwRNii6pcx-4Cb7g8UTrqnZHCxaoynntIrM/edit) by hoxyq, Error objects in CDT currently displays a big blob of string.

In this diff, we send the correct CDT params.

Reviewed By: hoxyq

Differential Revision: D60598446

fbshipit-source-id: 527c4e5858dfb879a32b40e5ad4df73a22e694e5
  • Loading branch information
EdmondChuiHW authored and facebook-github-bot committed Aug 16, 2024
1 parent 17017d2 commit 1740a56
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,31 @@ TEST_P(ConsoleApiTest, testConsoleError) {
eval("console.error('uh oh');");
}

TEST_P(ConsoleApiTest, testConsoleLogWithErrorObject) {
InSequence s;
expectConsoleApiCall(AllOf(
AtJsonPtr("/type", "log"),
AtJsonPtr("/args/0/type", "object"),
AtJsonPtr("/args/0/subtype", "error"),
AtJsonPtr("/args/0/className", "Error"),
AtJsonPtr(
"/args/0/description",
"Error: wut\n"
" at secondFunction (<eval>:6:28)\n"
" at firstFunction (<eval>:3:21)\n"
" at anonymous (<eval>:8:18)\n"
" at global (<eval>:9:5)")));
eval(R"((() => {
function firstFunction() {
secondFunction();
}
function secondFunction() {
console.log(new Error('wut'));
}
firstFunction();
})())");
}

TEST_P(ConsoleApiTest, testConsoleWarn) {
InSequence s;
expectConsoleApiCall(AllOf(
Expand Down

0 comments on commit 1740a56

Please sign in to comment.