{"action":"created","issue":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/33","labels_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/33/comments","events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/33/events","html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/33","id":128127340,"number":33,"title":"Subsidy API implementation and Integration test","user":{"login":"DedrickEnc","id":5418919,"avatar_url":"https://avatars.githubusercontent.com/u/5418919?v=3","gravatar_id":"","url":"https://api.github.com/users/DedrickEnc","html_url":"https://github.com/DedrickEnc","followers_url":"https://api.github.com/users/DedrickEnc/followers","following_url":"https://api.github.com/users/DedrickEnc/following{/other_user}","gists_url":"https://api.github.com/users/DedrickEnc/gists{/gist_id}","starred_url":"https://api.github.com/users/DedrickEnc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DedrickEnc/subscriptions","organizations_url":"https://api.github.com/users/DedrickEnc/orgs","repos_url":"https://api.github.com/users/DedrickEnc/repos","events_url":"https://api.github.com/users/DedrickEnc/events{/privacy}","received_events_url":"https://api.github.com/users/DedrickEnc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-01-22T10:33:09Z","updated_at":"2016-01-22T20:45:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/33","html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/33","diff_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/33.diff","patch_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/33.patch"},"body":"In this PR, I implemented the subsidy API and tested all routes\r\nThe subsidy API has methods :\r\nPOST\r\nGET\r\nPUT\r\nDELETE\r\n\r\nThe codes.js was updated to add more error cases, the routes.js file was updated too."},"comment":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/comments/174041511","html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/33#issuecomment-174041511","issue_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/33","id":174041511,"user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"created_at":"2016-01-22T20:45:28Z","updated_at":"2016-01-22T20:45:28Z","body":"Normally,  `checkData()` should crash the process.  It uses a `throw` statement without being in the context of a `try`/`catch` block, or in a promise.  However, it doesn't because of weird behavior in NodeJS.\r\n\r\nIt turns out that there is a difference in errors are created in Chrome and NodeJS.  It is unclear to me why this is the case, since it contradicts the [MDN documentation for throw](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw).\r\n```js\r\n// in the chrome browser, all of these generate an exception\r\nthrow new Error('This is an error from a String');\r\nthrow Error('This also works, without the new statement');\r\nthrow 'In fact, you don't need the Error name, you can just write a string...  No call stack though.';\r\n\r\n// in NodeJS the two following generate an exception and crash the process\r\nthrow new Error('This is an error from a String');\r\nthrow Error('This also works, without the new statement');\r\n// ... but this doesn't!\r\nthrow 'Why doesn\\'t NodeJS abide by JavaScript standards?';\r\n```\r\nI will accept this PR since it doesn't crash the process like I thought (I pulled your branch locally and wrote two more integration tests to try it).\r\n\r\nHowever, in the future, because of NodeJS's non-standard behavior, I will change req.codes to export error objects instead of plain objects, which will break this PR.  I'll add in the new tests in that PR and make sure that the process doesn't crash."}}