Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #804 Json parsing errors mention JSON.parse in errors #1001

Merged
merged 2 commits into from
Jun 6, 2016
Merged

Fixes #804 Json parsing errors mention JSON.parse in errors #1001

merged 2 commits into from
Jun 6, 2016

Conversation

nojvek
Copy link

@nojvek nojvek commented May 18, 2016

I added JSON.parse specific errors. It still doesn't feel very clean as there is no column info. Would this be relatively easy to add?

@msftclas
Copy link

Hi @nojvek, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Manoj Patel). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@ianwjhalliday
Copy link
Collaborator

Thanks @nojvek, these new error messages are definitely more helpful.

The error stack will have the line column information for the source of the throw, which will be where the JSON.parse call occurred, so we do have that already.

Could also be useful to have character offset (or line/column?) information for the source of the error in the JSON string passed to parse. I don't know if that would require much additional work on in the JSON parser or not. Certainly this can be raised as a new separate Suggestion issue if you think it is a good idea.

@abchatra any concerns over adding new error messages?

@nojvek
Copy link
Author

nojvek commented May 19, 2016

Right now there seems to be a LSC_ERROR_MSG(..) macro definition of a
syntax error.

How do I throw a syntax error with a dynamically created string ?

On Wed, May 18, 2016 at 2:03 PM, Ian Halliday [email protected]
wrote:

Thanks @nojvek https://github.com/nojvek, these new error messages are
definitely more helpful.

The error stack will have the line column information for the source of
the throw, which will be where the JSON.parse call occurred, so we do have
that already.

Could also be useful to have character offset (or line/column?)
information for the source of the error in the JSON string passed to parse.
I don't know if that would require much additional work on in the JSON
parser or not. Certainly this can be raised as a new separate Suggestion
issue if you think it is a good idea.

@abchatra https://github.com/abchatra any concerns over adding new
error messages?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1001 (comment)

@ianwjhalliday
Copy link
Collaborator

Look at rterrors.h where we have errors with two forms of their message string. The first form has a %s parameter that will be replaced by the given string to the JavascriptError::Throw* methods.

I believe you should be able to move the errors to rterrors.h and still use them for ThrowSyntaxError without any issues.

@abchatra
Copy link
Contributor

@abchatra any concerns over adding new error messages?

I am happy to see improvement in the error messages.

@nojvek
Copy link
Author

nojvek commented May 21, 2016

Thanks abchatra for the help today. I have made the fixes to show the position just like v8 does for JSON.parse. wdyt?

@ianwjhalliday
Copy link
Collaborator

Looks great! Thanks @nojvek, I'll get this merged.

@ianwjhalliday
Copy link
Collaborator

@nojvek turns out we have some JSON tests that do not run in jenkins currently because they depend on timezone.

You will need to manually run these two tests, test/JSON/jx2.js and test/es5/jx2.js, and update their baselines to match your change before we can merge this in. These two tests happen to run with no ch.exe command line switches, but in general when running tests manually you'd want to confirm you are using the right switches by examining the test/.../rlexe.xml file to see if it specifies switches and if so what they are. Also this will show you what the baseline file is named, sometimes it doesn't match the source file.

I also just noticed that your new test syntaxerror.js is not added to test/JSON/rlexe.xml. Please add it there so that it runs in the test runner.

@ianwjhalliday
Copy link
Collaborator

Note the json tests that don't run in jenkins because of their timezone dependency is an understood issue that we have not fixed yet. It depends on PST timezone.

return object;
}

default:
Js::JavascriptError::ThrowSyntaxError(scriptContext, ERRsyntax);
m_scanner.ThrowSyntaxError(JSERR_JsonSyntax);
return NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not required. This statement won't be reached.

Copy link
Author

Choose a reason for hiding this comment

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

Without this C++ won't compile.

e:\personal\chakracore\lib\runtime\library\jsonparser.cpp(415): warning C4715: 'JSON::JSONParser::ParseObject': not all control paths return a value

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is because JSONScanner::ThrowSyntaxError is not marked with __declspec(noreturn).

Probably reasonable to change the definition of JSONScanner::ThrowSyntaxError to:

void __declspec(noreturn) ThrowSyntaxError(int wErr)

Copy link
Author

Choose a reason for hiding this comment

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

done.

@nojvek
Copy link
Author

nojvek commented May 31, 2016

Ensured tests pass in runtests.cmd -x64 -debug and added syntaxError.js to rl.xml

@ianwjhalliday
Copy link
Collaborator

@nojvek you forgot to update the baseline for test\es5\jx2.js as well.

@nojvek
Copy link
Author

nojvek commented Jun 1, 2016

Oh forgot that. I updated Json/jx2.js

On Wednesday, June 1, 2016, Ian Halliday [email protected] wrote:

@nojvek https://github.com/nojvek you forgot to update the baseline for
test\es5\jx2.js as well.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1001 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AA-JVFQNPXjf5SZyJzGzCqVO7-G9Su0vks5qHgkFgaJpZM4Ig4Jc
.

@ianwjhalliday
Copy link
Collaborator

@nojvek when you get a chance please update test\es5\jx3.baseline. I've updated internal test baselines so once you've done that I believe we'll be all ready to merge your change.

@nojvek
Copy link
Author

nojvek commented Jun 3, 2016

Done. Ran all 1655 tests and confirmed they passed.

Not sure why baseline for jx2.js was called jx3.js. I've renamed to
jx2.baseline.

Soz for delay

On Thursday, June 2, 2016, Ian Halliday [email protected] wrote:

@nojvek https://github.com/nojvek when you get a chance please update
test\es5\jx3.baseline. I've updated internal test baselines so once
you've done that I believe we'll be all ready to merge your change.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1001 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AA-JVKI0UcnShH3KDFscE4dJsXbvpJkKks5qH10xgaJpZM4Ig4Jc
.

@ianwjhalliday
Copy link
Collaborator

Awesome, thanks for the rename. I don't know why it was different either. Probably some historical reason that didn't get cleaned up nicely.

@nojvek
Copy link
Author

nojvek commented Jun 3, 2016

Would be great to see this go in today. Let me know if you need anything else from my side. Thanks

@chakrabot chakrabot merged commit 69f175d into chakra-core:master Jun 6, 2016
chakrabot pushed a commit that referenced this pull request Jun 6, 2016
…rors

Merge pull request #1001 from nojvek:master
I added JSON.parse specific errors. It still doesn't feel very clean as there is no column info. Would this be relatively easy to add?
@ianwjhalliday
Copy link
Collaborator

@nojvek we're all good, merged! Thanks for improving these error messages

@nojvek
Copy link
Author

nojvek commented Jun 6, 2016

That's awesome. Thanks Ian.

On Mon, Jun 6, 2016 at 2:18 PM, Ian Halliday [email protected]
wrote:

@nojvek https://github.com/nojvek we're all good, merged! Thanks for
improving these error messages


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1001 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AA-JVDjgc-Yok9s9XJygkux6ofi-Wcupks5qJI60gaJpZM4Ig4Jc
.

@abchatra
Copy link
Contributor

abchatra commented Jun 6, 2016

Thank you @nojvek

@dilijev
Copy link
Contributor

dilijev commented Jun 6, 2016

Note that we're tracking the timezone-sensitive tests issue in #319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants