{"action":"created","comment":{"url":"https://api.github.com/repos/uber/tchannel/pulls/comments/38335707","id":38335707,"diff_hunk":"@@ -240,6 +228,37 @@ TChannelHTTP.prototype.forwardToTChannel = function forwardToTChannel(tchannel,\n     }\n };\n \n+TChannelHTTP.prototype._sendHTTPError = function _sendHTTPError(hres, error) {\n+    var codeName = errors.classify(error);\n+    switch (codeName) {\n+        case 'Cancelled':\n+            hres.writeHead(500, 'TChannel Cancelled');\n+            break;\n+        case 'Unhealthy':\n+        case 'Declined':\n+            hres.writeHead(503, 'Service Unavailable');\n+            break;\n+        case 'Timeout':\n+            hres.writeHead(504, 'Gateway Timeout');\n+            break;\n+        case 'BadRequest':\n+            hres.writeHead(400, 'Bad Request');\n+            break;\n+        case 'Busy':\n+            hres.writeHead(429, 'Too Many Requests');\n+            break;\n+        case 'ProtocolError':\n+            hres.writeHead(500, 'TChannel Protocol Error');\n+            break;\n+        case 'NetworkError':\n+            hres.writeHead(500, 'TChannel Network Error');\n+            break;\n+        default:\n+            hres.writeHead(500, 'Internal Server Error');\n+    }\n+    hres.end(error.message);","path":"node/as/http.js","position":72,"original_position":71,"commit_id":"c2cd89f6c1c97dded5a47e58182d7aaf83843aa6","original_commit_id":"2bb2769f4903dc44a5e1d8cacf8fc2283a417cc3","user":{"login":"anson627","id":1474346,"avatar_url":"https://avatars.githubusercontent.com/u/1474346?v=3","gravatar_id":"","url":"https://api.github.com/users/anson627","html_url":"https://github.com/anson627","followers_url":"https://api.github.com/users/anson627/followers","following_url":"https://api.github.com/users/anson627/following{/other_user}","gists_url":"https://api.github.com/users/anson627/gists{/gist_id}","starred_url":"https://api.github.com/users/anson627/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anson627/subscriptions","organizations_url":"https://api.github.com/users/anson627/orgs","repos_url":"https://api.github.com/users/anson627/repos","events_url":"https://api.github.com/users/anson627/events{/privacy}","received_events_url":"https://api.github.com/users/anson627/received_events","type":"User","site_admin":false},"body":"'Content-Type' is set to 'text/plain'.\r\n\r\nThe error message is good enough for the body, since the header already has status code and status message.\r\n","created_at":"2015-08-31T17:28:46Z","updated_at":"2015-08-31T17:28:46Z","html_url":"https://github.com/uber/tchannel/pull/1243#discussion_r38335707","pull_request_url":"https://api.github.com/repos/uber/tchannel/pulls/1243","_links":{"self":{"href":"https://api.github.com/repos/uber/tchannel/pulls/comments/38335707"},"html":{"href":"https://github.com/uber/tchannel/pull/1243#discussion_r38335707"},"pull_request":{"href":"https://api.github.com/repos/uber/tchannel/pulls/1243"}}},"pull_request":{"url":"https://api.github.com/repos/uber/tchannel/pulls/1243","id":43684329,"html_url":"https://github.com/uber/tchannel/pull/1243","diff_url":"https://github.com/uber/tchannel/pull/1243.diff","patch_url":"https://github.com/uber/tchannel/pull/1243.patch","issue_url":"https://api.github.com/repos/uber/tchannel/issues/1243","number":1243,"state":"open","locked":false,"title":"Improve errors mapping between tchannel and http","user":{"login":"anson627","id":1474346,"avatar_url":"https://avatars.githubusercontent.com/u/1474346?v=3","gravatar_id":"","url":"https://api.github.com/users/anson627","html_url":"https://github.com/anson627","followers_url":"https://api.github.com/users/anson627/followers","following_url":"https://api.github.com/users/anson627/following{/other_user}","gists_url":"https://api.github.com/users/anson627/gists{/gist_id}","starred_url":"https://api.github.com/users/anson627/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anson627/subscriptions","organizations_url":"https://api.github.com/users/anson627/orgs","repos_url":"https://api.github.com/users/anson627/repos","events_url":"https://api.github.com/users/anson627/events{/privacy}","received_events_url":"https://api.github.com/users/anson627/received_events","type":"User","site_admin":false},"body":"based on:\r\nhttps://github.com/uber/tchannel/blob/master/docs/error-mapping-tchannel-http.md\r\nr: @jcorbin @kriskowal @ShanniLi \r\ncc: @davewhat @vipulaneja ","created_at":"2015-08-29T00:30:54Z","updated_at":"2015-08-31T17:28:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f8ade9491fb0d1f7feef417ba46096593a6cb6f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/uber/tchannel/pulls/1243/commits","review_comments_url":"https://api.github.com/repos/uber/tchannel/pulls/1243/comments","review_comment_url":"https://api.github.com/repos/uber/tchannel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uber/tchannel/issues/1243/comments","statuses_url":"https://api.github.com/repos/uber/tchannel/statuses/c2cd89f6c1c97dded5a47e58182d7aaf83843aa6","head":{"label":"uber:as-http-errors","ref":"as-http-errors","sha":"c2cd89f6c1c97dded5a47e58182d7aaf83843aa6","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":28419663,"name":"tchannel","full_name":"uber/tchannel","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/tchannel","description":"network multiplexing and framing protocol for RPC","fork":false,"url":"https://api.github.com/repos/uber/tchannel","forks_url":"https://api.github.com/repos/uber/tchannel/forks","keys_url":"https://api.github.com/repos/uber/tchannel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/tchannel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/tchannel/teams","hooks_url":"https://api.github.com/repos/uber/tchannel/hooks","issue_events_url":"https://api.github.com/repos/uber/tchannel/issues/events{/number}","events_url":"https://api.github.com/repos/uber/tchannel/events","assignees_url":"https://api.github.com/repos/uber/tchannel/assignees{/user}","branches_url":"https://api.github.com/repos/uber/tchannel/branches{/branch}","tags_url":"https://api.github.com/repos/uber/tchannel/tags","blobs_url":"https://api.github.com/repos/uber/tchannel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/tchannel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/tchannel/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/tchannel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/tchannel/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/tchannel/languages","stargazers_url":"https://api.github.com/repos/uber/tchannel/stargazers","contributors_url":"https://api.github.com/repos/uber/tchannel/contributors","subscribers_url":"https://api.github.com/repos/uber/tchannel/subscribers","subscription_url":"https://api.github.com/repos/uber/tchannel/subscription","commits_url":"https://api.github.com/repos/uber/tchannel/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/tchannel/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/tchannel/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/tchannel/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/tchannel/contents/{+path}","compare_url":"https://api.github.com/repos/uber/tchannel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/tchannel/merges","archive_url":"https://api.github.com/repos/uber/tchannel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/tchannel/downloads","issues_url":"https://api.github.com/repos/uber/tchannel/issues{/number}","pulls_url":"https://api.github.com/repos/uber/tchannel/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/tchannel/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/tchannel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/tchannel/labels{/name}","releases_url":"https://api.github.com/repos/uber/tchannel/releases{/id}","created_at":"2014-12-23T21:06:57Z","updated_at":"2015-08-31T07:56:55Z","pushed_at":"2015-08-31T17:13:16Z","git_url":"git://github.com/uber/tchannel.git","ssh_url":"git@github.com:uber/tchannel.git","clone_url":"https://github.com/uber/tchannel.git","svn_url":"https://github.com/uber/tchannel","homepage":"","size":20992,"stargazers_count":249,"watchers_count":249,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":92,"forks":31,"open_issues":92,"watchers":249,"default_branch":"master"}},"base":{"label":"uber:master","ref":"master","sha":"a1a640bf2f10692c9fef10f602764f0d6bcc83ae","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":28419663,"name":"tchannel","full_name":"uber/tchannel","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/tchannel","description":"network multiplexing and framing protocol for RPC","fork":false,"url":"https://api.github.com/repos/uber/tchannel","forks_url":"https://api.github.com/repos/uber/tchannel/forks","keys_url":"https://api.github.com/repos/uber/tchannel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/tchannel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/tchannel/teams","hooks_url":"https://api.github.com/repos/uber/tchannel/hooks","issue_events_url":"https://api.github.com/repos/uber/tchannel/issues/events{/number}","events_url":"https://api.github.com/repos/uber/tchannel/events","assignees_url":"https://api.github.com/repos/uber/tchannel/assignees{/user}","branches_url":"https://api.github.com/repos/uber/tchannel/branches{/branch}","tags_url":"https://api.github.com/repos/uber/tchannel/tags","blobs_url":"https://api.github.com/repos/uber/tchannel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/tchannel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/tchannel/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/tchannel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/tchannel/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/tchannel/languages","stargazers_url":"https://api.github.com/repos/uber/tchannel/stargazers","contributors_url":"https://api.github.com/repos/uber/tchannel/contributors","subscribers_url":"https://api.github.com/repos/uber/tchannel/subscribers","subscription_url":"https://api.github.com/repos/uber/tchannel/subscription","commits_url":"https://api.github.com/repos/uber/tchannel/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/tchannel/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/tchannel/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/tchannel/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/tchannel/contents/{+path}","compare_url":"https://api.github.com/repos/uber/tchannel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/tchannel/merges","archive_url":"https://api.github.com/repos/uber/tchannel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/tchannel/downloads","issues_url":"https://api.github.com/repos/uber/tchannel/issues{/number}","pulls_url":"https://api.github.com/repos/uber/tchannel/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/tchannel/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/tchannel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/tchannel/labels{/name}","releases_url":"https://api.github.com/repos/uber/tchannel/releases{/id}","created_at":"2014-12-23T21:06:57Z","updated_at":"2015-08-31T07:56:55Z","pushed_at":"2015-08-31T17:13:16Z","git_url":"git://github.com/uber/tchannel.git","ssh_url":"git@github.com:uber/tchannel.git","clone_url":"https://github.com/uber/tchannel.git","svn_url":"https://github.com/uber/tchannel","homepage":"","size":20992,"stargazers_count":249,"watchers_count":249,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":92,"forks":31,"open_issues":92,"watchers":249,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uber/tchannel/pulls/1243"},"html":{"href":"https://github.com/uber/tchannel/pull/1243"},"issue":{"href":"https://api.github.com/repos/uber/tchannel/issues/1243"},"comments":{"href":"https://api.github.com/repos/uber/tchannel/issues/1243/comments"},"review_comments":{"href":"https://api.github.com/repos/uber/tchannel/pulls/1243/comments"},"review_comment":{"href":"https://api.github.com/repos/uber/tchannel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uber/tchannel/pulls/1243/commits"},"statuses":{"href":"https://api.github.com/repos/uber/tchannel/statuses/c2cd89f6c1c97dded5a47e58182d7aaf83843aa6"}}}}