Include file path in Syntax error messages (#2941)
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
This commit is contained in:
+22
-8
@@ -396,10 +396,17 @@ jerry_parse (const jerry_char_t *resource_name_p, /**< resource name (usually a
|
||||
#if ENABLED (JERRY_PARSER)
|
||||
jerry_assert_api_available ();
|
||||
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
JERRY_CONTEXT (resource_name) = ecma_find_or_create_literal_string (resource_name_p,
|
||||
(lit_utf8_size_t) resource_name_length);
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES)
|
||||
if (resource_name_length == 0)
|
||||
{
|
||||
JERRY_CONTEXT (resource_name) = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_CONTEXT (resource_name) = ecma_find_or_create_literal_string (resource_name_p,
|
||||
(lit_utf8_size_t) resource_name_length);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) */
|
||||
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
ecma_value_t parse_status;
|
||||
@@ -468,10 +475,17 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
ecma_value_t parse_status;
|
||||
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
JERRY_CONTEXT (resource_name) = ecma_find_or_create_literal_string (resource_name_p,
|
||||
(lit_utf8_size_t) resource_name_length);
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES)
|
||||
if (resource_name_length == 0)
|
||||
{
|
||||
JERRY_CONTEXT (resource_name) = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_CONTEXT (resource_name) = ecma_find_or_create_literal_string (resource_name_p,
|
||||
(lit_utf8_size_t) resource_name_length);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) */
|
||||
|
||||
if (arg_list_p == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user