Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Fixed various bugs around Error object #85

Merged
merged 1 commit into from
Jun 28, 2016

Conversation

kunalspathak
Copy link
Member

Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • the commit message follows commit guidelines
Affected core subsystem(s)

chakrashim

Description of change

Fixed various bugs around Error object. Individual commits has description.

Fixes: #70 , #75, #78

@kunalspathak
Copy link
Member Author

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]);

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?

Copy link
Member Author

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]);

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@jianchun
Copy link

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>
@kunalspathak kunalspathak merged commit 32b85f9 into nodejs:chakracore-master Jun 28, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants