-
Notifications
You must be signed in to change notification settings - Fork 340
Conversation
FYI - @nodejs/node-chakracore |
var splittedStack = stack.split('\n'); | ||
splittedStack.splice(0, skipDepth + 1); // also skip top name/message line | ||
var errstack = []; | ||
|
||
for (var i = 0; i < splittedStack.length; i++) { | ||
var parens = /\(/.exec(splittedStack[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OT: given that parens
is only used for its index
, wouldn't splittedStack[i].indexOf('(')
be more desirable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but we need parens to get the index down, so just reused parens
instead.
var errstack = []; | ||
|
||
for (var i = 0; i < splittedStack.length; i++) { | ||
var parens = /\(/.exec(splittedStack[i]); | ||
var funcName = splittedStack[i].substr(6, parens.index - 7); | ||
var stackDetails = reStackDetails.exec(splittedStack[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this line move down so that it won't run when skipDepth > 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
LGTM 👍 |
1. We parse error stack in chakra_shim to make it simliar to that of v8. However we were missing the case if stack messages has `\n`. Fixed it. Fixes: nodejs#78 2. Fixed Error.captureStackTrace Since `chakra_shim.js` that patches `Error.captureStackTrace` runs under strict mode, it was not able to get caller information. Having caller information is much reliable in captureStackTrace than matching using `function.name`. Removed `use strict` and disabled eslint rule for `use strict`. This helped in matching caller exactly regardless of name of form `o.p.q` in `Error.captureStackTrace`. Fixes: nodejs#75 3. Added missing functions on StackFrame Added following missing methods on StackFrame: * getFunction * getMethodName * getTypeName * isConstructor * isToplevel * isNative Implemented `getFunction`. `getFunction` currently works if `.stack` is called from same callsite where `new Error()` or `Error.captureStackTrace()` was called. However currently we don't record and store the callstack when these functions were called and so we lose the information of `.caller` when called later while populating `e.stack`. If we save the callstack, we would be holding references to all the functions in the callstack which doesn't seem right. I have added a TODO to solve this, but wanted to send this out so we get better coverage on node compatibility. Fixes : nodejs#70 PR-URL: nodejs#85 Reviewed-By: Jianchun Xu <Jianchun.Xu@microsoft.com>
Checklist
make -j4 test
(UNIX) orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
chakrashim
Description of change
Fixed various bugs around Error object. Individual commits has description.
Fixes: #70 , #75, #78