{"action":"created","issue":{"url":"https://api.github.com/repos/yargs/yargs/issues/455","repository_url":"https://api.github.com/repos/yargs/yargs","labels_url":"https://api.github.com/repos/yargs/yargs/issues/455/labels{/name}","comments_url":"https://api.github.com/repos/yargs/yargs/issues/455/comments","events_url":"https://api.github.com/repos/yargs/yargs/issues/455/events","html_url":"https://github.com/yargs/yargs/issues/455","id":143751934,"number":455,"title":"Sync error of handler should throw a global error","user":{"login":"satazor","id":1017236,"avatar_url":"https://avatars.githubusercontent.com/u/1017236?v=3","gravatar_id":"","url":"https://api.github.com/users/satazor","html_url":"https://github.com/satazor","followers_url":"https://api.github.com/users/satazor/followers","following_url":"https://api.github.com/users/satazor/following{/other_user}","gists_url":"https://api.github.com/users/satazor/gists{/gist_id}","starred_url":"https://api.github.com/users/satazor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/satazor/subscriptions","organizations_url":"https://api.github.com/users/satazor/orgs","repos_url":"https://api.github.com/users/satazor/repos","events_url":"https://api.github.com/users/satazor/events{/privacy}","received_events_url":"https://api.github.com/users/satazor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-26T21:43:30Z","updated_at":"2016-03-26T22:07:32Z","closed_at":null,"body":"```\r\n// foo.js\r\n'use strict';\r\n\r\nconst yargs = require('yargs');\r\n\r\nyargs\r\n.help('help').alias('help', 'h')\r\n.command('foo', 'Foo command is awesome', () => {\r\n    console.log('foo handler');\r\n    throw new Error('This error will show below the help');\r\n})\r\n.argv;\r\n```\r\n\r\nIf you now run `node foo` it will show the usage and the error below.\r\n\r\n<img width=\"716\" alt=\"screen shot 2016-03-26 at 21 39 45\" src=\"https://cloud.githubusercontent.com/assets/1017236/14062557/8585162c-f39b-11e5-8f4c-603e4e8a8f64.png\">\r\n\r\nI was expecting the error to be thrown globally and not being handled by yargs.\r\n\r\nyargs version: 4.3.2\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yargs/yargs/issues/comments/201939885","html_url":"https://github.com/yargs/yargs/issues/455#issuecomment-201939885","issue_url":"https://api.github.com/repos/yargs/yargs/issues/455","id":201939885,"user":{"login":"nexdrew","id":1929625,"avatar_url":"https://avatars.githubusercontent.com/u/1929625?v=3","gravatar_id":"","url":"https://api.github.com/users/nexdrew","html_url":"https://github.com/nexdrew","followers_url":"https://api.github.com/users/nexdrew/followers","following_url":"https://api.github.com/users/nexdrew/following{/other_user}","gists_url":"https://api.github.com/users/nexdrew/gists{/gist_id}","starred_url":"https://api.github.com/users/nexdrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nexdrew/subscriptions","organizations_url":"https://api.github.com/users/nexdrew/orgs","repos_url":"https://api.github.com/users/nexdrew/repos","events_url":"https://api.github.com/users/nexdrew/events{/privacy}","received_events_url":"https://api.github.com/users/nexdrew/received_events","type":"User","site_admin":false},"created_at":"2016-03-26T22:07:32Z","updated_at":"2016-03-26T22:07:32Z","body":"Ok, I see. If you want to customize this behavior, I think you need to define your own `.fail()` function.\r\n\r\n```js\r\nyargs.fail((msg, err) => {\r\n  // do something here, maybe throw err\r\n})\r\n```\r\n\r\nLet us know how that works for you."}}