Include file path in Syntax error messages#2941
Merged
dbatyai merged 1 commit intojerryscript-project:masterfrom Jul 11, 2019
Merged
Include file path in Syntax error messages#2941dbatyai merged 1 commit intojerryscript-project:masterfrom
dbatyai merged 1 commit intojerryscript-project:masterfrom
Conversation
rerobika
reviewed
Jul 3, 2019
759e0ae to
8805d4e
Compare
galpeter
reviewed
Jul 3, 2019
| #if ENABLED (JERRY_LINE_INFO) | ||
| #if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) | ||
| ecma_value_t resource_name; /**< resource name (usually a file name) */ | ||
| #endif /* ENABLED (JERRY_LINE_INFO) */ |
Contributor
There was a problem hiding this comment.
The comment for #endif should also be updated.
| num_str[j] = '\0'; | ||
|
|
||
| i += 10; | ||
| err_line = (unsigned int) strtol (num_str, NULL, 10); |
Contributor
There was a problem hiding this comment.
As the strtol is used, we could leverage it to in every case where the str->number conversion is required. With it we would not need to manually copy the chars into the num_str array, just point the start of the string where the number should be and it will return the the end pointer where the value is not convertible. This would reduce a bit of code here.
| jerry_release_value (parsed_code_val); | ||
| TEST_ASSERT (!strcmp ((char *) err_str_buf, | ||
| "SyntaxError: Primary expression expected. [line: 2, column: 10]")); | ||
| "SyntaxError: Primary expression expected. [<anonymous>:2:10]")); |
Contributor
There was a problem hiding this comment.
A test for the normal case ( having a file path ) would be good.
d680442 to
304022a
Compare
Member
|
@dbatyai Please rebase the PR. |
When using ES6 modules it was not possible to identify which module an error originates from. This PR changes the error message to also include the file path using the file:line:column format, and updates the source context printing for unhandled exceptions to use the correct file. Co-authored-by: Marko Fabo <mfabo@inf.u-szeged.hu> JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
304022a to
754ab06
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using ES6 modules it was not possible to identify which module
an error originates from.
This PR changes the error message to also include the file path using
the file:line:column format, and updates the source context printing for
unhandled exceptions to use the correct file.
Co-authored-by: Marko Fabo mfabo@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu