Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
src: fix JSError inspection
This commit fixes JSError inspection for Node.js v7+. We still need to
figure out a way to get the stack from the Error object though.

Ref: #143
  • Loading branch information
Matheus Marchini authored and mmarchini committed Sep 11, 2018
commit 22588ccf93c549f526475325c3e59c66457d59f7
1 change: 1 addition & 0 deletions src/llv8-constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ void Types::Load() {
kFirstContextType = LoadConstant("FirstContextType");
kLastContextType = LoadConstant("LastContextType");

kJSErrorType = LoadConstant("type_JSError__JS_ERROR_TYPE");
kHeapNumberType = LoadConstant("type_HeapNumber__HEAP_NUMBER_TYPE");
kMapType = LoadConstant("type_Map__MAP_TYPE");
kGlobalObjectType =
Expand Down
1 change: 1 addition & 0 deletions src/llv8-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ class Types : public Module {
int64_t kFirstContextType;
int64_t kLastContextType;

int64_t kJSErrorType;
int64_t kHeapNumberType;
int64_t kMapType;
int64_t kGlobalObjectType;
Expand Down
1 change: 1 addition & 0 deletions src/llv8-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ ACCESSOR(JSObject, Elements, js_object()->kElementsOffset, HeapObject)
inline bool JSObject::IsObjectType(LLV8* v8, int64_t type) {
return type == v8->types()->kJSObjectType ||
type == v8->types()->kJSAPIObjectType ||
type == v8->types()->kJSErrorType ||
type == v8->types()->kJSSpecialAPIObjectType;
}

Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/inspect-scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ function closure() {
);
c.hashmap['buffer'] = Buffer.from([0xff, 0xf0, 0x80, 0x0f, 0x01, 0x00]);

c.hashmap['error'] = new Error('test');
c.hashmap['error'].code = 'ERR_TEST';
c.hashmap['error'].errno = 1;

c.hashmap[0] = null;
c.hashmap[4] = undefined;
c.hashmap[23] = /regexp/;
Expand Down
5 changes: 5 additions & 0 deletions test/plugin/inspect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ const hashMapTests = {
re: /.sliced-externalized-string=(0x[0-9a-f]+):<String: "\(external\)">/,
desc: '.sliced-externalized-string Sliced ExternalString property'
},
// .error=0x0000392d5d661119:<Object: Error>

This comment was marked as off-topic.

This comment was marked as off-topic.

'error': {
re: /.error=(0x[0-9a-f]+):<Object: Error>/,
desc: '.error Error property'
},
// .array=0x000003df9cbe7919:<Array: length=6>,
'array': {
re: /.array=(0x[0-9a-f]+):<Array: length=6>/,
Expand Down