Skip to content

Commit e9dce27

Browse files
committed
Render Error objects in CDT
Summary: 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. Differential Revision: D60598446
1 parent 05ee71f commit e9dce27

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

API/hermes/cdp/RemoteObjectConverters.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ std::vector<m::debugger::CallFrame> m::debugger::makeCallFrames(
231231
return result;
232232
}
233233

234+
static bool isObjectInstanceOfError(
235+
const jsi::Object &obj,
236+
facebook::jsi::Runtime &runtime) {
237+
return obj.instanceOf(
238+
runtime, runtime.global().getPropertyAsFunction(runtime, "Error"));
239+
}
240+
234241
m::runtime::RemoteObject m::runtime::makeRemoteObject(
235242
facebook::jsi::Runtime &runtime,
236243
const facebook::jsi::Value &value,
@@ -309,6 +316,12 @@ m::runtime::RemoteObject m::runtime::makeRemoteObject(
309316
if (options.generatePreview) {
310317
result.preview = generateArrayPreview(runtime, array);
311318
}
319+
} else if (isObjectInstanceOfError(obj, runtime)) {
320+
result.type = "object";
321+
result.subtype = "error";
322+
result.className = "Error";
323+
result.description =
324+
obj.getProperty(runtime, "stack").toString(runtime).utf8(runtime);
312325
} else {
313326
result.type = "object";
314327
result.description = result.className = "Object";

0 commit comments

Comments
 (0)