{"action":"opened","issue":{"url":"https://api.github.com/repos/qualitybath/bunyan-slack/issues/7","labels_url":"https://api.github.com/repos/qualitybath/bunyan-slack/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/qualitybath/bunyan-slack/issues/7/comments","events_url":"https://api.github.com/repos/qualitybath/bunyan-slack/issues/7/events","html_url":"https://github.com/qualitybath/bunyan-slack/issues/7","id":77996361,"number":7,"title":"Usage of this in request error","user":{"login":"sabrehagen","id":1094600,"avatar_url":"https://avatars.githubusercontent.com/u/1094600?v=3","gravatar_id":"","url":"https://api.github.com/users/sabrehagen","html_url":"https://github.com/sabrehagen","followers_url":"https://api.github.com/users/sabrehagen/followers","following_url":"https://api.github.com/users/sabrehagen/following{/other_user}","gists_url":"https://api.github.com/users/sabrehagen/gists{/gist_id}","starred_url":"https://api.github.com/users/sabrehagen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sabrehagen/subscriptions","organizations_url":"https://api.github.com/users/sabrehagen/orgs","repos_url":"https://api.github.com/users/sabrehagen/repos","events_url":"https://api.github.com/users/sabrehagen/events{/privacy}","received_events_url":"https://api.github.com/users/sabrehagen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-19T08:41:59Z","updated_at":"2015-05-19T08:41:59Z","closed_at":null,"body":"I see you have a test to make sure your error handler is being run. I can't run your tests on my machine as I receive the following error, but your travis-ci build suggests that the test passes.\r\n\r\nIn the following code block, in .on('error') you are returning `this.error`, but `this` will have lost its context when the error event fires, so you should really take a reference to `this` outside the request call, for example `var self = this`, then reference `return self.error(error)`. I believe your code will fail otherwise!\r\n\r\n\trequest.post({\r\n\t\turl: this.webhook_url,\r\n\t\tbody: JSON.stringify(message)\r\n\t})\r\n\t.on('error', function(err) {\r\n\t\treturn this.error(err);\r\n    });\r\n\r\nMy attempt at running your tests - maybe a mocha issue?\r\n```\r\n$ npm test\r\n\r\n> bunyan-slack@0.0.8 test C:\\repositories\\bunyan-slack\r\n> istanbul cover _mocha --report lcovonly\r\n\r\nNo coverage information was collected, exit without writing coverage information\r\nC:\\repositories\\bunyan-slack\\node_modules\\.bin\\_mocha.CMD:1\r\n(function (exports, require, module, __filename, __dirname) { @IF EXIST \"%~dp0\r\n                                                              ^\r\nSyntaxError: Unexpected token ILLEGAL\r\n    at exports.runInThisContext (vm.js:53:16)\r\n    at Module._compile (module.js:414:25)\r\n    at Object.Module._extensions..js (module.js:449:10)\r\n    at Object.Module._extensions.(anonymous function) [as .js] (C:\\repositories\\bunyan-slack\\node_modules\\istanbul\\lib\\hook.js:107:37)\r\n    at Module.load (module.js:356:32)\r\n    at Function.Module._load (module.js:311:12)\r\n    at Function.Module.runMain (module.js:472:10)\r\n    at runFn (C:\\repositories\\bunyan-slack\\node_modules\\istanbul\\lib\\command\\common\\run-with-cover.js:122:16)\r\n    at C:\\repositories\\bunyan-slack\\node_modules\\istanbul\\lib\\command\\common\\run-with-cover.js:248:17\r\n    at C:\\repositories\\bunyan-slack\\node_modules\\istanbul\\lib\\util\\file-matcher.js:68:16\r\nnpm ERR! Test failed.  See above for more details.\r\n```"}}