-
Notifications
You must be signed in to change notification settings - Fork 688
Include file path in Syntax error messages #2941
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
Include file path in Syntax error messages #2941
Conversation
759e0ae to
8805d4e
Compare
jerry-core/jcontext/jcontext.h
Outdated
| #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) */ |
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.
The comment for #endif should also be updated.
| num_str[j] = '\0'; | ||
|
|
||
| i += 10; | ||
| err_line = (unsigned int) strtol (num_str, NULL, 10); |
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.
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]")); |
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.
A test for the normal case ( having a file path ) would be good.
d680442 to
304022a
Compare
rerobika
left a comment
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.
LGTM
galpeter
left a comment
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.
lgtm
|
@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
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