Skip to content

Commit 080f089

Browse files
committed
Render Error objects in CDT (facebook#45990)
Summary: Pull Request resolved: facebook#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
1 parent 7d088f8 commit 080f089

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/react-native/ReactCommon/jsinspector-modern/tests/ConsoleApiTest.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,31 @@ TEST_P(ConsoleApiTest, testConsoleError) {
281281
eval("console.error('uh oh');");
282282
}
283283

284+
TEST_P(ConsoleApiTest, testConsoleLogWithErrorObject) {
285+
InSequence s;
286+
expectConsoleApiCall(AllOf(
287+
AtJsonPtr("/type", "log"),
288+
AtJsonPtr("/args/0/type", "object"),
289+
AtJsonPtr("/args/0/subtype", "error"),
290+
AtJsonPtr("/args/0/className", "Error"),
291+
AtJsonPtr(
292+
"/args/0/description",
293+
"Error: wut\n"
294+
" at secondFunction (<eval>:6:28)\n"
295+
" at firstFunction (<eval>:3:21)\n"
296+
" at anonymous (<eval>:8:18)\n"
297+
" at global (<eval>:9:5)")));
298+
eval(R"((() => {
299+
function firstFunction() {
300+
secondFunction();
301+
}
302+
function secondFunction() {
303+
console.log(new Error('wut'));
304+
}
305+
firstFunction();
306+
})())");
307+
}
308+
284309
TEST_P(ConsoleApiTest, testConsoleWarn) {
285310
InSequence s;
286311
expectConsoleApiCall(AllOf(

0 commit comments

Comments
 (0)