{"action":"closed","number":208,"pull_request":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/208","id":63886104,"html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/208","diff_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/208.diff","patch_url":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/208.patch","issue_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/208","number":208,"state":"closed","locked":false,"title":"feat: create API error functions","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},"body":"This commit creates error functions for common HTTP error status codes.\r\nThe following have been implemented:\r\n 1. BadRequest [400]\r\n 2. Unauthorized [401]\r\n 3. Forbidden [403]\r\n 4. NotFound [404]\r\n 5. InternalServerError [500]\r\n\r\nError functions are really easy to import and use in controllers.  See\r\nthe following example:\r\n```js\r\n\r\nconst NotFound = require('lib/errors/NotFound');\r\n\r\n// throw the error to demonstrate that it is an error\r\ntry {\r\n  throw new NotFound('An example description.');\r\n\r\n  // NOTE - this used to be done like this:\r\n  // throw new req.codes.ERR_NOT_FOUND();\r\n\r\n// pass the error to the first error handling middleware\r\n} catch (e) {\r\n  next(e);\r\n}\r\n```\r\n\r\n**NOTE** - this commit __deprecates__ the use of `req.codes`.  All\r\ncontroller code should now import the codes they need and no longer\r\ndepend the on `req.codes` property, as it will be removed in the future.\r\n\r\nCloses #182.","created_at":"2016-03-23T14:01:40Z","updated_at":"2016-03-23T14:28:43Z","closed_at":"2016-03-23T14:28:43Z","merged_at":"2016-03-23T14:28:43Z","merge_commit_sha":"131dcc35f6e32dc132d9dedfe11013294f4e6891","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/208/commits","review_comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/208/comments","review_comment_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/208/comments","statuses_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/dd930a58f6ecc3531e830da1bdc503df5bb6a677","head":{"label":"jniles:issue-182","ref":"issue-182","sha":"dd930a58f6ecc3531e830da1bdc503df5bb6a677","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},"repo":{"id":49059888,"name":"bhima-2.X","full_name":"jniles/bhima-2.X","owner":{"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},"private":false,"html_url":"https://github.com/jniles/bhima-2.X","description":"A fresh start for bhima to remove large commits","fork":true,"url":"https://api.github.com/repos/jniles/bhima-2.X","forks_url":"https://api.github.com/repos/jniles/bhima-2.X/forks","keys_url":"https://api.github.com/repos/jniles/bhima-2.X/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jniles/bhima-2.X/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jniles/bhima-2.X/teams","hooks_url":"https://api.github.com/repos/jniles/bhima-2.X/hooks","issue_events_url":"https://api.github.com/repos/jniles/bhima-2.X/issues/events{/number}","events_url":"https://api.github.com/repos/jniles/bhima-2.X/events","assignees_url":"https://api.github.com/repos/jniles/bhima-2.X/assignees{/user}","branches_url":"https://api.github.com/repos/jniles/bhima-2.X/branches{/branch}","tags_url":"https://api.github.com/repos/jniles/bhima-2.X/tags","blobs_url":"https://api.github.com/repos/jniles/bhima-2.X/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jniles/bhima-2.X/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jniles/bhima-2.X/git/refs{/sha}","trees_url":"https://api.github.com/repos/jniles/bhima-2.X/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jniles/bhima-2.X/statuses/{sha}","languages_url":"https://api.github.com/repos/jniles/bhima-2.X/languages","stargazers_url":"https://api.github.com/repos/jniles/bhima-2.X/stargazers","contributors_url":"https://api.github.com/repos/jniles/bhima-2.X/contributors","subscribers_url":"https://api.github.com/repos/jniles/bhima-2.X/subscribers","subscription_url":"https://api.github.com/repos/jniles/bhima-2.X/subscription","commits_url":"https://api.github.com/repos/jniles/bhima-2.X/commits{/sha}","git_commits_url":"https://api.github.com/repos/jniles/bhima-2.X/git/commits{/sha}","comments_url":"https://api.github.com/repos/jniles/bhima-2.X/comments{/number}","issue_comment_url":"https://api.github.com/repos/jniles/bhima-2.X/issues/comments{/number}","contents_url":"https://api.github.com/repos/jniles/bhima-2.X/contents/{+path}","compare_url":"https://api.github.com/repos/jniles/bhima-2.X/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jniles/bhima-2.X/merges","archive_url":"https://api.github.com/repos/jniles/bhima-2.X/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jniles/bhima-2.X/downloads","issues_url":"https://api.github.com/repos/jniles/bhima-2.X/issues{/number}","pulls_url":"https://api.github.com/repos/jniles/bhima-2.X/pulls{/number}","milestones_url":"https://api.github.com/repos/jniles/bhima-2.X/milestones{/number}","notifications_url":"https://api.github.com/repos/jniles/bhima-2.X/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jniles/bhima-2.X/labels{/name}","releases_url":"https://api.github.com/repos/jniles/bhima-2.X/releases{/id}","deployments_url":"https://api.github.com/repos/jniles/bhima-2.X/deployments","created_at":"2016-01-05T10:44:42Z","updated_at":"2016-01-05T10:44:44Z","pushed_at":"2016-03-23T14:06:17Z","git_url":"git://github.com/jniles/bhima-2.X.git","ssh_url":"git@github.com:jniles/bhima-2.X.git","clone_url":"https://github.com/jniles/bhima-2.X.git","svn_url":"https://github.com/jniles/bhima-2.X","homepage":null,"size":2684,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"IMA-WorldHealth:master","ref":"master","sha":"593270eade42d83e9ff9e9bbd6cc89ccfcdaa868","user":{"login":"IMA-WorldHealth","id":5330583,"avatar_url":"https://avatars.githubusercontent.com/u/5330583?v=3","gravatar_id":"","url":"https://api.github.com/users/IMA-WorldHealth","html_url":"https://github.com/IMA-WorldHealth","followers_url":"https://api.github.com/users/IMA-WorldHealth/followers","following_url":"https://api.github.com/users/IMA-WorldHealth/following{/other_user}","gists_url":"https://api.github.com/users/IMA-WorldHealth/gists{/gist_id}","starred_url":"https://api.github.com/users/IMA-WorldHealth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IMA-WorldHealth/subscriptions","organizations_url":"https://api.github.com/users/IMA-WorldHealth/orgs","repos_url":"https://api.github.com/users/IMA-WorldHealth/repos","events_url":"https://api.github.com/users/IMA-WorldHealth/events{/privacy}","received_events_url":"https://api.github.com/users/IMA-WorldHealth/received_events","type":"Organization","site_admin":false},"repo":{"id":49052669,"name":"bhima-2.X","full_name":"IMA-WorldHealth/bhima-2.X","owner":{"login":"IMA-WorldHealth","id":5330583,"avatar_url":"https://avatars.githubusercontent.com/u/5330583?v=3","gravatar_id":"","url":"https://api.github.com/users/IMA-WorldHealth","html_url":"https://github.com/IMA-WorldHealth","followers_url":"https://api.github.com/users/IMA-WorldHealth/followers","following_url":"https://api.github.com/users/IMA-WorldHealth/following{/other_user}","gists_url":"https://api.github.com/users/IMA-WorldHealth/gists{/gist_id}","starred_url":"https://api.github.com/users/IMA-WorldHealth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IMA-WorldHealth/subscriptions","organizations_url":"https://api.github.com/users/IMA-WorldHealth/orgs","repos_url":"https://api.github.com/users/IMA-WorldHealth/repos","events_url":"https://api.github.com/users/IMA-WorldHealth/events{/privacy}","received_events_url":"https://api.github.com/users/IMA-WorldHealth/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/IMA-WorldHealth/bhima-2.X","description":"A fresh start for bhima to remove large commits","fork":false,"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X","forks_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/forks","keys_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/teams","hooks_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/hooks","issue_events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/events{/number}","events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/events","assignees_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/assignees{/user}","branches_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/branches{/branch}","tags_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/tags","blobs_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/refs{/sha}","trees_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/{sha}","languages_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/languages","stargazers_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/stargazers","contributors_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/contributors","subscribers_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/subscribers","subscription_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/subscription","commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/commits{/sha}","git_commits_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/git/commits{/sha}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/comments{/number}","issue_comment_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/comments{/number}","contents_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/contents/{+path}","compare_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/merges","archive_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/downloads","issues_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues{/number}","pulls_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls{/number}","milestones_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/milestones{/number}","notifications_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/labels{/name}","releases_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/releases{/id}","deployments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/deployments","created_at":"2016-01-05T08:30:30Z","updated_at":"2016-02-27T20:42:18Z","pushed_at":"2016-03-23T14:28:43Z","git_url":"git://github.com/IMA-WorldHealth/bhima-2.X.git","ssh_url":"git@github.com:IMA-WorldHealth/bhima-2.X.git","clone_url":"https://github.com/IMA-WorldHealth/bhima-2.X.git","svn_url":"https://github.com/IMA-WorldHealth/bhima-2.X","homepage":null,"size":2974,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":55,"forks":5,"open_issues":55,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/208"},"html":{"href":"https://github.com/IMA-WorldHealth/bhima-2.X/pull/208"},"issue":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/208"},"comments":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/208/comments"},"review_comments":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/208/comments"},"review_comment":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/pulls/208/commits"},"statuses":{"href":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/statuses/dd930a58f6ecc3531e830da1bdc503df5bb6a677"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"sfount","id":2844572,"avatar_url":"https://avatars.githubusercontent.com/u/2844572?v=3","gravatar_id":"","url":"https://api.github.com/users/sfount","html_url":"https://github.com/sfount","followers_url":"https://api.github.com/users/sfount/followers","following_url":"https://api.github.com/users/sfount/following{/other_user}","gists_url":"https://api.github.com/users/sfount/gists{/gist_id}","starred_url":"https://api.github.com/users/sfount/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfount/subscriptions","organizations_url":"https://api.github.com/users/sfount/orgs","repos_url":"https://api.github.com/users/sfount/repos","events_url":"https://api.github.com/users/sfount/events{/privacy}","received_events_url":"https://api.github.com/users/sfount/received_events","type":"User","site_admin":false},"comments":1,"review_comments":0,"commits":1,"additions":328,"deletions":29,"changed_files":14}}