{"action":"created","issue":{"url":"https://api.github.com/repos/jerryscript-project/jerryscript/issues/1577","repository_url":"https://api.github.com/repos/jerryscript-project/jerryscript","labels_url":"https://api.github.com/repos/jerryscript-project/jerryscript/issues/1577/labels{/name}","comments_url":"https://api.github.com/repos/jerryscript-project/jerryscript/issues/1577/comments","events_url":"https://api.github.com/repos/jerryscript-project/jerryscript/issues/1577/events","html_url":"https://github.com/jerryscript-project/jerryscript/pull/1577","id":206807651,"number":1577,"title":"Improve error message","user":{"login":"bsdelf","id":555268,"avatar_url":"https://avatars.githubusercontent.com/u/555268?v=3","gravatar_id":"","url":"https://api.github.com/users/bsdelf","html_url":"https://github.com/bsdelf","followers_url":"https://api.github.com/users/bsdelf/followers","following_url":"https://api.github.com/users/bsdelf/following{/other_user}","gists_url":"https://api.github.com/users/bsdelf/gists{/gist_id}","starred_url":"https://api.github.com/users/bsdelf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsdelf/subscriptions","organizations_url":"https://api.github.com/users/bsdelf/orgs","repos_url":"https://api.github.com/users/bsdelf/repos","events_url":"https://api.github.com/users/bsdelf/events{/privacy}","received_events_url":"https://api.github.com/users/bsdelf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-02-10T14:21:34Z","updated_at":"2017-02-10T14:48:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/jerryscript-project/jerryscript/pulls/1577","html_url":"https://github.com/jerryscript-project/jerryscript/pull/1577","diff_url":"https://github.com/jerryscript-project/jerryscript/pull/1577.diff","patch_url":"https://github.com/jerryscript-project/jerryscript/pull/1577.patch"},"body":"Many error messages of JerryScript only tell there is an error but without further context, which is vague and makes it difficult to debug.\r\n\r\nThis patch helps the situtation, for errors related to unexisting properties or bad references, it can remind the property/variable names at least.\r\n\r\nWith this patch, for the following testing code (also works for `node`):\r\n\r\n```javascript\r\n'use strict';\r\n\r\nvar print = print || console.log;\r\n\r\nvar printError = (function (i) {\r\n  return function (head, error) {\r\n    print(i + (i <= 9 ? ' ' : ''), head, Array(30 - head.length).join(' '), error);\r\n      print(Array(100).join('-'));\r\n      ++i;\r\n  };\r\n})(1);\r\n\r\n[ 'x = 1;',\r\n  'x += 1;',\r\n  'var y = x;',\r\n  'x.y = 1;',\r\n  'var x; x.y;',\r\n  'var x; x.y = 1;',\r\n  'var x = null; x[\\'y\\'];',\r\n  'null.y = 1;'\r\n].forEach(function (src) {\r\n  try {\r\n    eval(src);\r\n  } catch (e) {\r\n    printError(src, e);\r\n  }\r\n});\r\n\r\n```\r\n\r\nThe expected output would be:\r\n\r\n```\r\n1  x = 1;                         ReferenceError: x is not defined\r\n---------------------------------------------------------------------------------------------------\r\n2  x += 1;                        ReferenceError: x is not defined\r\n---------------------------------------------------------------------------------------------------\r\n3  var y = x;                     ReferenceError: x is not defined\r\n---------------------------------------------------------------------------------------------------\r\n4  x.y = 1;                       ReferenceError: x is not defined\r\n---------------------------------------------------------------------------------------------------\r\n5  var x; x.y;                    TypeError: Cannot read property 'y' of undefined\r\n---------------------------------------------------------------------------------------------------\r\n6  var x; x.y = 1;                TypeError: Cannot set property 'y' of undefined\r\n---------------------------------------------------------------------------------------------------\r\n7  var x = null; x['y'];          TypeError: Cannot read property 'y' of null\r\n---------------------------------------------------------------------------------------------------\r\n8  null.y = 1;                    TypeError: Cannot set property 'y' of null\r\n---------------------------------------------------------------------------------------------------\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/jerryscript-project/jerryscript/issues/comments/278961122","html_url":"https://github.com/jerryscript-project/jerryscript/pull/1577#issuecomment-278961122","issue_url":"https://api.github.com/repos/jerryscript-project/jerryscript/issues/1577","id":278961122,"user":{"login":"dbatyai","id":12066566,"avatar_url":"https://avatars.githubusercontent.com/u/12066566?v=3","gravatar_id":"","url":"https://api.github.com/users/dbatyai","html_url":"https://github.com/dbatyai","followers_url":"https://api.github.com/users/dbatyai/followers","following_url":"https://api.github.com/users/dbatyai/following{/other_user}","gists_url":"https://api.github.com/users/dbatyai/gists{/gist_id}","starred_url":"https://api.github.com/users/dbatyai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbatyai/subscriptions","organizations_url":"https://api.github.com/users/dbatyai/orgs","repos_url":"https://api.github.com/users/dbatyai/repos","events_url":"https://api.github.com/users/dbatyai/events{/privacy}","received_events_url":"https://api.github.com/users/dbatyai/received_events","type":"User","site_admin":false},"created_at":"2017-02-10T14:48:44Z","updated_at":"2017-02-10T14:48:44Z","body":"The `JERRY_ENABLE_ERROR_MESSAGES` already exists and would be suitable here as well, so no need for a new one."}}
{"actor":{"display_login":"dbatyai"}}