Skip to content

Conversation

@dbatyai
Copy link
Member

@dbatyai dbatyai commented Jul 2, 2019

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

@rerobika rerobika added the ES2015 Related to ES2015 features label Jul 3, 2019
@dbatyai dbatyai force-pushed the module_error_messages branch from 759e0ae to 8805d4e Compare July 3, 2019 08:54
#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) */
Copy link
Contributor

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);
Copy link
Contributor

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]"));
Copy link
Contributor

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.

@dbatyai dbatyai force-pushed the module_error_messages branch 2 times, most recently from d680442 to 304022a Compare July 4, 2019 13:39
Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

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

LGTM

@dbatyai dbatyai requested a review from galpeter July 5, 2019 11:58
Copy link
Contributor

@galpeter galpeter left a comment

Choose a reason for hiding this comment

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

lgtm

@rerobika
Copy link
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
@dbatyai dbatyai force-pushed the module_error_messages branch from 304022a to 754ab06 Compare July 11, 2019 09:28
@dbatyai dbatyai merged commit c304b9a into jerryscript-project:master Jul 11, 2019
@dbatyai dbatyai deleted the module_error_messages branch July 25, 2019 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ES2015 Related to ES2015 features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants