Skip to content

Commit 22588cc

Browse files
Matheus Marchinimmarchini
Matheus Marchini
authored andcommitted
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: nodejs#143
1 parent 5cf24d0 commit 22588cc

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

src/llv8-constants.cc

+1
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ void Types::Load() {
490490
kFirstContextType = LoadConstant("FirstContextType");
491491
kLastContextType = LoadConstant("LastContextType");
492492

493+
kJSErrorType = LoadConstant("type_JSError__JS_ERROR_TYPE");
493494
kHeapNumberType = LoadConstant("type_HeapNumber__HEAP_NUMBER_TYPE");
494495
kMapType = LoadConstant("type_Map__MAP_TYPE");
495496
kGlobalObjectType =

src/llv8-constants.h

+1
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ class Types : public Module {
478478
int64_t kFirstContextType;
479479
int64_t kLastContextType;
480480

481+
int64_t kJSErrorType;
481482
int64_t kHeapNumberType;
482483
int64_t kMapType;
483484
int64_t kGlobalObjectType;

src/llv8-inl.h

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ ACCESSOR(JSObject, Elements, js_object()->kElementsOffset, HeapObject)
211211
inline bool JSObject::IsObjectType(LLV8* v8, int64_t type) {
212212
return type == v8->types()->kJSObjectType ||
213213
type == v8->types()->kJSAPIObjectType ||
214+
type == v8->types()->kJSErrorType ||
214215
type == v8->types()->kJSSpecialAPIObjectType;
215216
}
216217

test/fixtures/inspect-scenario.js

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ function closure() {
5757
);
5858
c.hashmap['buffer'] = Buffer.from([0xff, 0xf0, 0x80, 0x0f, 0x01, 0x00]);
5959

60+
c.hashmap['error'] = new Error('test');
61+
c.hashmap['error'].code = 'ERR_TEST';
62+
c.hashmap['error'].errno = 1;
63+
6064
c.hashmap[0] = null;
6165
c.hashmap[4] = undefined;
6266
c.hashmap[23] = /regexp/;

test/plugin/inspect-test.js

+5
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ const hashMapTests = {
133133
re: /.sliced-externalized-string=(0x[0-9a-f]+):<String: "\(external\)">/,
134134
desc: '.sliced-externalized-string Sliced ExternalString property'
135135
},
136+
// .error=0x0000392d5d661119:<Object: Error>
137+
'error': {
138+
re: /.error=(0x[0-9a-f]+):<Object: Error>/,
139+
desc: '.error Error property'
140+
},
136141
// .array=0x000003df9cbe7919:<Array: length=6>,
137142
'array': {
138143
re: /.array=(0x[0-9a-f]+):<Array: length=6>/,

0 commit comments

Comments
 (0)