{"action":"created","comment":{"url":"https://api.github.com/repos/webpack/webpack/pulls/comments/101465405","pull_request_review_id":22193722,"id":101465405,"diff_hunk":"@@ -51,15 +51,16 @@ class WebpackOptionsValidationError extends Error {\n \tconstructor(validationErrors) {\n \t\tsuper();\n \n-\t\tif(Error.hasOwnProperty(\"captureStackTrace\")) {\n-\t\t\tError.captureStackTrace(this, this.constructor);\n-\t\t}\n \t\tthis.name = \"WebpackOptionsValidationError\";\n \n \t\tthis.message = \"Invalid configuration object. \" +\n \t\t\t\"Webpack has been initialised using a configuration object that does not match the API schema.\\n\" +\n \t\t\tvalidationErrors.map(err => \" - \" + indent(WebpackOptionsValidationError.formatValidationError(err), \"   \", false)).join(\"\\n\");\n \t\tthis.validationErrors = validationErrors;\n+\n+\t\tif(Error.hasOwnProperty(\"captureStackTrace\")) {","path":"lib/WebpackOptionsValidationError.js","position":14,"original_position":14,"commit_id":"ff96f7188ae402be300fde341ba1d2b093562f31","original_commit_id":"ff96f7188ae402be300fde341ba1d2b093562f31","user":{"login":"sokra","id":1365881,"avatar_url":"https://avatars.githubusercontent.com/u/1365881?v=3","gravatar_id":"","url":"https://api.github.com/users/sokra","html_url":"https://github.com/sokra","followers_url":"https://api.github.com/users/sokra/followers","following_url":"https://api.github.com/users/sokra/following{/other_user}","gists_url":"https://api.github.com/users/sokra/gists{/gist_id}","starred_url":"https://api.github.com/users/sokra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sokra/subscriptions","organizations_url":"https://api.github.com/users/sokra/orgs","repos_url":"https://api.github.com/users/sokra/repos","events_url":"https://api.github.com/users/sokra/events{/privacy}","received_events_url":"https://api.github.com/users/sokra/received_events","type":"User","site_admin":false},"body":"Here is one check left over.","created_at":"2017-02-16T08:28:24Z","updated_at":"2017-02-16T08:28:30Z","html_url":"https://github.com/webpack/webpack/pull/4257#discussion_r101465405","pull_request_url":"https://api.github.com/repos/webpack/webpack/pulls/4257","_links":{"self":{"href":"https://api.github.com/repos/webpack/webpack/pulls/comments/101465405"},"html":{"href":"https://github.com/webpack/webpack/pull/4257#discussion_r101465405"},"pull_request":{"href":"https://api.github.com/repos/webpack/webpack/pulls/4257"}}},"pull_request":{"url":"https://api.github.com/repos/webpack/webpack/pulls/4257","id":105719752,"html_url":"https://github.com/webpack/webpack/pull/4257","diff_url":"https://github.com/webpack/webpack/pull/4257.diff","patch_url":"https://github.com/webpack/webpack/pull/4257.patch","issue_url":"https://api.github.com/repos/webpack/webpack/issues/4257","number":4257,"state":"open","locked":false,"title":"Fix Error Formatting Issue","user":{"login":"jescalan","id":556932,"avatar_url":"https://avatars.githubusercontent.com/u/556932?v=3","gravatar_id":"","url":"https://api.github.com/users/jescalan","html_url":"https://github.com/jescalan","followers_url":"https://api.github.com/users/jescalan/followers","following_url":"https://api.github.com/users/jescalan/following{/other_user}","gists_url":"https://api.github.com/users/jescalan/gists{/gist_id}","starred_url":"https://api.github.com/users/jescalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jescalan/subscriptions","organizations_url":"https://api.github.com/users/jescalan/orgs","repos_url":"https://api.github.com/users/jescalan/repos","events_url":"https://api.github.com/users/jescalan/events{/privacy}","received_events_url":"https://api.github.com/users/jescalan/received_events","type":"User","site_admin":false},"body":"So at the moment, when there is a validation error, it only outputs the stack trace, and not the actual error message. Simple reproduction:\r\n\r\n```js\r\nconst webpack = require('webpack')\r\nwebpack({ foo: 'bar' })\r\n```\r\n\r\nIf you run this, you'll see that the stack trace shows up, but not the actual error message, which is pretty unfortunate.\r\n\r\n```\r\n[...]/webpack/lib/webpack.js:19\r\n\t\tthrow new WebpackOptionsValidationError(webpackOptionsValidationErrors);\r\n\t\t^\r\n\r\nError\r\n    at webpack ([..]/webpack/lib/webpack.js:19:9)\r\n    at Object.<anonymous> ([...]/test.js:3:1)\r\n    at Module._compile (module.js:571:32)\r\n    at Object.Module._extensions..js (module.js:580:10)\r\n    at Module.load (module.js:488:32)\r\n    at tryModuleLoad (module.js:447:12)\r\n    at Function.Module._load (module.js:439:3)\r\n    at Module.runMain (module.js:605:10)\r\n    at run (bootstrap_node.js:418:7)\r\n    at startup (bootstrap_node.js:139:9)\r\n```\r\n\r\nI messed around with this for a while and was rather confused about why it happens, and finally stumbled across the answer. Basically, when you call `Error.captureStackTrace`, it not only captures and sets the `MyError.stack` property, it also messed with the error message a bit.\r\n\r\n> \"The first line of the trace, instead of being prefixed with ErrorType: message, will be the result of calling targetObject.toString().\"\r\n> -- [The Docs](https://nodejs.org/api/errors.html#errors_error_capturestacktrace_targetobject_constructoropt)\r\n\r\nIt does this immediately upon being called, so in this instance, it was calling `toString` on the instance **before** the error message was set, and therefore setting the error message to blank, leaving only the stack trace to show up when the error is thrown.\r\n\r\nThe fix here is simply moving it down to the bottom of the constructor, where it will run after the error message has been set. When I tested this, the error message was logged out correctly as expected 🙌 ","created_at":"2017-02-10T22:43:34Z","updated_at":"2017-02-16T08:28:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f9639c026e26a3a4d29a7a1fce0a9e7f293249d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/webpack/webpack/pulls/4257/commits","review_comments_url":"https://api.github.com/repos/webpack/webpack/pulls/4257/comments","review_comment_url":"https://api.github.com/repos/webpack/webpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/4257/comments","statuses_url":"https://api.github.com/repos/webpack/webpack/statuses/ff96f7188ae402be300fde341ba1d2b093562f31","head":{"label":"jescalan:je.error-fix","ref":"je.error-fix","sha":"ff96f7188ae402be300fde341ba1d2b093562f31","user":{"login":"jescalan","id":556932,"avatar_url":"https://avatars.githubusercontent.com/u/556932?v=3","gravatar_id":"","url":"https://api.github.com/users/jescalan","html_url":"https://github.com/jescalan","followers_url":"https://api.github.com/users/jescalan/followers","following_url":"https://api.github.com/users/jescalan/following{/other_user}","gists_url":"https://api.github.com/users/jescalan/gists{/gist_id}","starred_url":"https://api.github.com/users/jescalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jescalan/subscriptions","organizations_url":"https://api.github.com/users/jescalan/orgs","repos_url":"https://api.github.com/users/jescalan/repos","events_url":"https://api.github.com/users/jescalan/events{/privacy}","received_events_url":"https://api.github.com/users/jescalan/received_events","type":"User","site_admin":false},"repo":{"id":59150980,"name":"webpack","full_name":"jescalan/webpack","owner":{"login":"jescalan","id":556932,"avatar_url":"https://avatars.githubusercontent.com/u/556932?v=3","gravatar_id":"","url":"https://api.github.com/users/jescalan","html_url":"https://github.com/jescalan","followers_url":"https://api.github.com/users/jescalan/followers","following_url":"https://api.github.com/users/jescalan/following{/other_user}","gists_url":"https://api.github.com/users/jescalan/gists{/gist_id}","starred_url":"https://api.github.com/users/jescalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jescalan/subscriptions","organizations_url":"https://api.github.com/users/jescalan/orgs","repos_url":"https://api.github.com/users/jescalan/repos","events_url":"https://api.github.com/users/jescalan/events{/privacy}","received_events_url":"https://api.github.com/users/jescalan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jescalan/webpack","description":"A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows to load parts for the application on demand. Through \"loaders\" modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.","fork":true,"url":"https://api.github.com/repos/jescalan/webpack","forks_url":"https://api.github.com/repos/jescalan/webpack/forks","keys_url":"https://api.github.com/repos/jescalan/webpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jescalan/webpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jescalan/webpack/teams","hooks_url":"https://api.github.com/repos/jescalan/webpack/hooks","issue_events_url":"https://api.github.com/repos/jescalan/webpack/issues/events{/number}","events_url":"https://api.github.com/repos/jescalan/webpack/events","assignees_url":"https://api.github.com/repos/jescalan/webpack/assignees{/user}","branches_url":"https://api.github.com/repos/jescalan/webpack/branches{/branch}","tags_url":"https://api.github.com/repos/jescalan/webpack/tags","blobs_url":"https://api.github.com/repos/jescalan/webpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jescalan/webpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jescalan/webpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/jescalan/webpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jescalan/webpack/statuses/{sha}","languages_url":"https://api.github.com/repos/jescalan/webpack/languages","stargazers_url":"https://api.github.com/repos/jescalan/webpack/stargazers","contributors_url":"https://api.github.com/repos/jescalan/webpack/contributors","subscribers_url":"https://api.github.com/repos/jescalan/webpack/subscribers","subscription_url":"https://api.github.com/repos/jescalan/webpack/subscription","commits_url":"https://api.github.com/repos/jescalan/webpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/jescalan/webpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/jescalan/webpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/jescalan/webpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/jescalan/webpack/contents/{+path}","compare_url":"https://api.github.com/repos/jescalan/webpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jescalan/webpack/merges","archive_url":"https://api.github.com/repos/jescalan/webpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jescalan/webpack/downloads","issues_url":"https://api.github.com/repos/jescalan/webpack/issues{/number}","pulls_url":"https://api.github.com/repos/jescalan/webpack/pulls{/number}","milestones_url":"https://api.github.com/repos/jescalan/webpack/milestones{/number}","notifications_url":"https://api.github.com/repos/jescalan/webpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jescalan/webpack/labels{/name}","releases_url":"https://api.github.com/repos/jescalan/webpack/releases{/id}","deployments_url":"https://api.github.com/repos/jescalan/webpack/deployments","created_at":"2016-05-18T21:01:44Z","updated_at":"2016-05-18T21:01:47Z","pushed_at":"2017-02-15T19:55:58Z","git_url":"git://github.com/jescalan/webpack.git","ssh_url":"git@github.com:jescalan/webpack.git","clone_url":"https://github.com/jescalan/webpack.git","svn_url":"https://github.com/jescalan/webpack","homepage":"https://webpack.github.io","size":6207,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"webpack:master","ref":"master","sha":"1cc7272c17c50524853e59cff72625829e8f24be","user":{"login":"webpack","id":2105791,"avatar_url":"https://avatars.githubusercontent.com/u/2105791?v=3","gravatar_id":"","url":"https://api.github.com/users/webpack","html_url":"https://github.com/webpack","followers_url":"https://api.github.com/users/webpack/followers","following_url":"https://api.github.com/users/webpack/following{/other_user}","gists_url":"https://api.github.com/users/webpack/gists{/gist_id}","starred_url":"https://api.github.com/users/webpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webpack/subscriptions","organizations_url":"https://api.github.com/users/webpack/orgs","repos_url":"https://api.github.com/users/webpack/repos","events_url":"https://api.github.com/users/webpack/events{/privacy}","received_events_url":"https://api.github.com/users/webpack/received_events","type":"Organization","site_admin":false},"repo":{"id":3678731,"name":"webpack","full_name":"webpack/webpack","owner":{"login":"webpack","id":2105791,"avatar_url":"https://avatars.githubusercontent.com/u/2105791?v=3","gravatar_id":"","url":"https://api.github.com/users/webpack","html_url":"https://github.com/webpack","followers_url":"https://api.github.com/users/webpack/followers","following_url":"https://api.github.com/users/webpack/following{/other_user}","gists_url":"https://api.github.com/users/webpack/gists{/gist_id}","starred_url":"https://api.github.com/users/webpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webpack/subscriptions","organizations_url":"https://api.github.com/users/webpack/orgs","repos_url":"https://api.github.com/users/webpack/repos","events_url":"https://api.github.com/users/webpack/events{/privacy}","received_events_url":"https://api.github.com/users/webpack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/webpack/webpack","description":"A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows to load parts for the application on demand. Through \"loaders,\" modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.","fork":false,"url":"https://api.github.com/repos/webpack/webpack","forks_url":"https://api.github.com/repos/webpack/webpack/forks","keys_url":"https://api.github.com/repos/webpack/webpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/webpack/webpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/webpack/webpack/teams","hooks_url":"https://api.github.com/repos/webpack/webpack/hooks","issue_events_url":"https://api.github.com/repos/webpack/webpack/issues/events{/number}","events_url":"https://api.github.com/repos/webpack/webpack/events","assignees_url":"https://api.github.com/repos/webpack/webpack/assignees{/user}","branches_url":"https://api.github.com/repos/webpack/webpack/branches{/branch}","tags_url":"https://api.github.com/repos/webpack/webpack/tags","blobs_url":"https://api.github.com/repos/webpack/webpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/webpack/webpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/webpack/webpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/webpack/webpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/webpack/webpack/statuses/{sha}","languages_url":"https://api.github.com/repos/webpack/webpack/languages","stargazers_url":"https://api.github.com/repos/webpack/webpack/stargazers","contributors_url":"https://api.github.com/repos/webpack/webpack/contributors","subscribers_url":"https://api.github.com/repos/webpack/webpack/subscribers","subscription_url":"https://api.github.com/repos/webpack/webpack/subscription","commits_url":"https://api.github.com/repos/webpack/webpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/webpack/webpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/webpack/webpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/webpack/webpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/webpack/webpack/contents/{+path}","compare_url":"https://api.github.com/repos/webpack/webpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/webpack/webpack/merges","archive_url":"https://api.github.com/repos/webpack/webpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/webpack/webpack/downloads","issues_url":"https://api.github.com/repos/webpack/webpack/issues{/number}","pulls_url":"https://api.github.com/repos/webpack/webpack/pulls{/number}","milestones_url":"https://api.github.com/repos/webpack/webpack/milestones{/number}","notifications_url":"https://api.github.com/repos/webpack/webpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/webpack/webpack/labels{/name}","releases_url":"https://api.github.com/repos/webpack/webpack/releases{/id}","deployments_url":"https://api.github.com/repos/webpack/webpack/deployments","created_at":"2012-03-10T10:08:14Z","updated_at":"2017-02-16T08:15:52Z","pushed_at":"2017-02-15T21:01:17Z","git_url":"git://github.com/webpack/webpack.git","ssh_url":"git@github.com:webpack/webpack.git","clone_url":"https://github.com/webpack/webpack.git","svn_url":"https://github.com/webpack/webpack","homepage":"https://webpack.js.org","size":6326,"stargazers_count":24270,"watchers_count":24270,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2854,"mirror_url":null,"open_issues_count":664,"forks":2854,"open_issues":664,"watchers":24270,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/webpack/webpack/pulls/4257"},"html":{"href":"https://github.com/webpack/webpack/pull/4257"},"issue":{"href":"https://api.github.com/repos/webpack/webpack/issues/4257"},"comments":{"href":"https://api.github.com/repos/webpack/webpack/issues/4257/comments"},"review_comments":{"href":"https://api.github.com/repos/webpack/webpack/pulls/4257/comments"},"review_comment":{"href":"https://api.github.com/repos/webpack/webpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/webpack/webpack/pulls/4257/commits"},"statuses":{"href":"https://api.github.com/repos/webpack/webpack/statuses/ff96f7188ae402be300fde341ba1d2b093562f31"}}}}
{"actor":{"display_login":"sokra"}}