{"action":"created","comment":{"url":"https://api.github.com/repos/flask-restful/flask-restful/pulls/comments/22719842","id":22719842,"diff_hunk":"@@ -272,15 +272,21 @@ def handle_error(self, e):\n         \"\"\"\n         got_request_exception.send(current_app._get_current_object(), exception=e)\n \n-        if not hasattr(e, 'code') and current_app.propagate_exceptions:\n+        if not isinstance(e, HTTPException) and current_app.propagate_exceptions:\n             exc_type, exc_value, tb = sys.exc_info()\n             if exc_value is e:\n                 raise\n             else:\n                 raise e\n \n-        code = getattr(e, 'code', 500)\n-        data = getattr(e, 'data', error_data(code))\n+        if isinstance(e, HTTPException):\n+            code = e.code\n+            data = getattr(e, 'data', error_data(code))","path":"flask_restful/__init__.py","position":16,"original_position":16,"commit_id":"12ec85187fcb853b7755b4fed8b7995a9e351727","original_commit_id":"12ec85187fcb853b7755b4fed8b7995a9e351727","user":{"login":"joshfriend","id":885137,"avatar_url":"https://avatars.githubusercontent.com/u/885137?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfriend","html_url":"https://github.com/joshfriend","followers_url":"https://api.github.com/users/joshfriend/followers","following_url":"https://api.github.com/users/joshfriend/following{/other_user}","gists_url":"https://api.github.com/users/joshfriend/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfriend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfriend/subscriptions","organizations_url":"https://api.github.com/users/joshfriend/orgs","repos_url":"https://api.github.com/users/joshfriend/repos","events_url":"https://api.github.com/users/joshfriend/events{/privacy}","received_events_url":"https://api.github.com/users/joshfriend/received_events","type":"User","site_admin":false},"body":"That test does seem to set up a somewhat unreasonable scenario.\r\n\r\nThose failing tests should also probably raise the right exception instead of changing the `code\r\n`test_handle_error` use `BadRequest`\r\n`test_handle_auth` use `Unauthorized`\r\n`test_handle_server_error` use `InternalServerError`","created_at":"2015-01-09T15:02:59Z","updated_at":"2015-01-09T15:02:59Z","html_url":"https://github.com/flask-restful/flask-restful/pull/342#discussion_r22719842","pull_request_url":"https://api.github.com/repos/flask-restful/flask-restful/pulls/342","_links":{"self":{"href":"https://api.github.com/repos/flask-restful/flask-restful/pulls/comments/22719842"},"html":{"href":"https://github.com/flask-restful/flask-restful/pull/342#discussion_r22719842"},"pull_request":{"href":"https://api.github.com/repos/flask-restful/flask-restful/pulls/342"}}},"pull_request":{"url":"https://api.github.com/repos/flask-restful/flask-restful/pulls/342","id":24621690,"html_url":"https://github.com/flask-restful/flask-restful/pull/342","diff_url":"https://github.com/flask-restful/flask-restful/pull/342.diff","patch_url":"https://github.com/flask-restful/flask-restful/pull/342.patch","issue_url":"https://api.github.com/repos/flask-restful/flask-restful/issues/342","number":342,"state":"open","locked":false,"title":"Check if the code is a proper integer before comparison","user":{"login":"newmaniese","id":64894,"avatar_url":"https://avatars.githubusercontent.com/u/64894?v=3","gravatar_id":"","url":"https://api.github.com/users/newmaniese","html_url":"https://github.com/newmaniese","followers_url":"https://api.github.com/users/newmaniese/followers","following_url":"https://api.github.com/users/newmaniese/following{/other_user}","gists_url":"https://api.github.com/users/newmaniese/gists{/gist_id}","starred_url":"https://api.github.com/users/newmaniese/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/newmaniese/subscriptions","organizations_url":"https://api.github.com/users/newmaniese/orgs","repos_url":"https://api.github.com/users/newmaniese/repos","events_url":"https://api.github.com/users/newmaniese/events{/privacy}","received_events_url":"https://api.github.com/users/newmaniese/received_events","type":"User","site_admin":false},"body":"Boto's [JSONReponseError](http://boto.readthedocs.org/en/latest/ref/boto.html#boto.exception.JSONResponseError) provides an attribute `code`, which makes Flask Restful break in the event that is the exception. This adds some very basic type checking to make sure that the real error isn't hidden.\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Users/newmaniese/VirtualEnvs/bobcat2/lib/python3.4/site-packages/flask/app.py\", line 1836, in __call__\r\n    return self.wsgi_app(environ, start_response)\r\n  File \"/Users/newmaniese/VirtualEnvs/bobcat2/lib/python3.4/site-packages/flask/app.py\", line 1820, in wsgi_app\r\n    response = self.make_response(self.handle_exception(e))\r\n  File \"/Users/newmaniese/VirtualEnvs/bobcat2/src/flaskrestful/flask_restful/__init__.py\", line 261, in error_router\r\n    return self.handle_error(e)\r\n  File \"/Users/newmaniese/VirtualEnvs/bobcat2/lib/python3.4/site-packages/flask/app.py\", line 1817, in wsgi_app\r\n    response = self.full_dispatch_request()\r\n  File \"/Users/newmaniese/VirtualEnvs/bobcat2/lib/python3.4/site-packages/flask/app.py\", line 1477, in full_dispatch_request\r\n    rv = self.handle_user_exception(e)\r\n  File \"/Users/newmaniese/VirtualEnvs/bobcat2/src/flaskrestful/flask_restful/__init__.py\", line 261, in error_router\r\n    return self.handle_error(e)\r\n  File \"/Users/newmaniese/VirtualEnvs/bobcat2/src/flaskrestful/flask_restful/__init__.py\", line 284, in handle_error\r\n    if code >= 500:\r\nTypeError: unorderable types: str() >= int()\r\n```\r\n","created_at":"2014-11-18T16:01:39Z","updated_at":"2015-01-09T15:02:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d9fb965089e8ddf17018ca026296a8a83e1ae81","assignee":null,"milestone":{"url":"https://api.github.com/repos/flask-restful/flask-restful/milestones/3","labels_url":"https://api.github.com/repos/flask-restful/flask-restful/milestones/3/labels","id":912669,"number":3,"title":"0.3.2","description":"","creator":{"login":"joshfriend","id":885137,"avatar_url":"https://avatars.githubusercontent.com/u/885137?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfriend","html_url":"https://github.com/joshfriend","followers_url":"https://api.github.com/users/joshfriend/followers","following_url":"https://api.github.com/users/joshfriend/following{/other_user}","gists_url":"https://api.github.com/users/joshfriend/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfriend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfriend/subscriptions","organizations_url":"https://api.github.com/users/joshfriend/orgs","repos_url":"https://api.github.com/users/joshfriend/repos","events_url":"https://api.github.com/users/joshfriend/events{/privacy}","received_events_url":"https://api.github.com/users/joshfriend/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":6,"state":"open","created_at":"2014-12-22T20:28:42Z","updated_at":"2015-01-09T00:31:29Z","due_on":"2015-01-11T05:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/flask-restful/flask-restful/pulls/342/commits","review_comments_url":"https://api.github.com/repos/flask-restful/flask-restful/pulls/342/comments","review_comment_url":"https://api.github.com/repos/flask-restful/flask-restful/pulls/comments/{number}","comments_url":"https://api.github.com/repos/flask-restful/flask-restful/issues/342/comments","statuses_url":"https://api.github.com/repos/flask-restful/flask-restful/statuses/12ec85187fcb853b7755b4fed8b7995a9e351727","head":{"label":"newmaniese:master","ref":"master","sha":"12ec85187fcb853b7755b4fed8b7995a9e351727","user":{"login":"newmaniese","id":64894,"avatar_url":"https://avatars.githubusercontent.com/u/64894?v=3","gravatar_id":"","url":"https://api.github.com/users/newmaniese","html_url":"https://github.com/newmaniese","followers_url":"https://api.github.com/users/newmaniese/followers","following_url":"https://api.github.com/users/newmaniese/following{/other_user}","gists_url":"https://api.github.com/users/newmaniese/gists{/gist_id}","starred_url":"https://api.github.com/users/newmaniese/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/newmaniese/subscriptions","organizations_url":"https://api.github.com/users/newmaniese/orgs","repos_url":"https://api.github.com/users/newmaniese/repos","events_url":"https://api.github.com/users/newmaniese/events{/privacy}","received_events_url":"https://api.github.com/users/newmaniese/received_events","type":"User","site_admin":false},"repo":{"id":26816980,"name":"flask-restful","full_name":"newmaniese/flask-restful","owner":{"login":"newmaniese","id":64894,"avatar_url":"https://avatars.githubusercontent.com/u/64894?v=3","gravatar_id":"","url":"https://api.github.com/users/newmaniese","html_url":"https://github.com/newmaniese","followers_url":"https://api.github.com/users/newmaniese/followers","following_url":"https://api.github.com/users/newmaniese/following{/other_user}","gists_url":"https://api.github.com/users/newmaniese/gists{/gist_id}","starred_url":"https://api.github.com/users/newmaniese/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/newmaniese/subscriptions","organizations_url":"https://api.github.com/users/newmaniese/orgs","repos_url":"https://api.github.com/users/newmaniese/repos","events_url":"https://api.github.com/users/newmaniese/events{/privacy}","received_events_url":"https://api.github.com/users/newmaniese/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/newmaniese/flask-restful","description":"Simple framework for creating REST APIs","fork":true,"url":"https://api.github.com/repos/newmaniese/flask-restful","forks_url":"https://api.github.com/repos/newmaniese/flask-restful/forks","keys_url":"https://api.github.com/repos/newmaniese/flask-restful/keys{/key_id}","collaborators_url":"https://api.github.com/repos/newmaniese/flask-restful/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/newmaniese/flask-restful/teams","hooks_url":"https://api.github.com/repos/newmaniese/flask-restful/hooks","issue_events_url":"https://api.github.com/repos/newmaniese/flask-restful/issues/events{/number}","events_url":"https://api.github.com/repos/newmaniese/flask-restful/events","assignees_url":"https://api.github.com/repos/newmaniese/flask-restful/assignees{/user}","branches_url":"https://api.github.com/repos/newmaniese/flask-restful/branches{/branch}","tags_url":"https://api.github.com/repos/newmaniese/flask-restful/tags","blobs_url":"https://api.github.com/repos/newmaniese/flask-restful/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/newmaniese/flask-restful/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/newmaniese/flask-restful/git/refs{/sha}","trees_url":"https://api.github.com/repos/newmaniese/flask-restful/git/trees{/sha}","statuses_url":"https://api.github.com/repos/newmaniese/flask-restful/statuses/{sha}","languages_url":"https://api.github.com/repos/newmaniese/flask-restful/languages","stargazers_url":"https://api.github.com/repos/newmaniese/flask-restful/stargazers","contributors_url":"https://api.github.com/repos/newmaniese/flask-restful/contributors","subscribers_url":"https://api.github.com/repos/newmaniese/flask-restful/subscribers","subscription_url":"https://api.github.com/repos/newmaniese/flask-restful/subscription","commits_url":"https://api.github.com/repos/newmaniese/flask-restful/commits{/sha}","git_commits_url":"https://api.github.com/repos/newmaniese/flask-restful/git/commits{/sha}","comments_url":"https://api.github.com/repos/newmaniese/flask-restful/comments{/number}","issue_comment_url":"https://api.github.com/repos/newmaniese/flask-restful/issues/comments/{number}","contents_url":"https://api.github.com/repos/newmaniese/flask-restful/contents/{+path}","compare_url":"https://api.github.com/repos/newmaniese/flask-restful/compare/{base}...{head}","merges_url":"https://api.github.com/repos/newmaniese/flask-restful/merges","archive_url":"https://api.github.com/repos/newmaniese/flask-restful/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/newmaniese/flask-restful/downloads","issues_url":"https://api.github.com/repos/newmaniese/flask-restful/issues{/number}","pulls_url":"https://api.github.com/repos/newmaniese/flask-restful/pulls{/number}","milestones_url":"https://api.github.com/repos/newmaniese/flask-restful/milestones{/number}","notifications_url":"https://api.github.com/repos/newmaniese/flask-restful/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/newmaniese/flask-restful/labels{/name}","releases_url":"https://api.github.com/repos/newmaniese/flask-restful/releases{/id}","created_at":"2014-11-18T15:56:50Z","updated_at":"2015-01-09T00:19:42Z","pushed_at":"2015-01-09T00:19:41Z","git_url":"git://github.com/newmaniese/flask-restful.git","ssh_url":"git@github.com:newmaniese/flask-restful.git","clone_url":"https://github.com/newmaniese/flask-restful.git","svn_url":"https://github.com/newmaniese/flask-restful","homepage":"http://flask-restful.readthedocs.org/en/latest/","size":706,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"flask-restful:master","ref":"master","sha":"bf983cf706c9f55e5789f621f2ce9182f01d9636","user":{"login":"flask-restful","id":9747573,"avatar_url":"https://avatars.githubusercontent.com/u/9747573?v=3","gravatar_id":"","url":"https://api.github.com/users/flask-restful","html_url":"https://github.com/flask-restful","followers_url":"https://api.github.com/users/flask-restful/followers","following_url":"https://api.github.com/users/flask-restful/following{/other_user}","gists_url":"https://api.github.com/users/flask-restful/gists{/gist_id}","starred_url":"https://api.github.com/users/flask-restful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flask-restful/subscriptions","organizations_url":"https://api.github.com/users/flask-restful/orgs","repos_url":"https://api.github.com/users/flask-restful/repos","events_url":"https://api.github.com/users/flask-restful/events{/privacy}","received_events_url":"https://api.github.com/users/flask-restful/received_events","type":"Organization","site_admin":false},"repo":{"id":6182775,"name":"flask-restful","full_name":"flask-restful/flask-restful","owner":{"login":"flask-restful","id":9747573,"avatar_url":"https://avatars.githubusercontent.com/u/9747573?v=3","gravatar_id":"","url":"https://api.github.com/users/flask-restful","html_url":"https://github.com/flask-restful","followers_url":"https://api.github.com/users/flask-restful/followers","following_url":"https://api.github.com/users/flask-restful/following{/other_user}","gists_url":"https://api.github.com/users/flask-restful/gists{/gist_id}","starred_url":"https://api.github.com/users/flask-restful/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flask-restful/subscriptions","organizations_url":"https://api.github.com/users/flask-restful/orgs","repos_url":"https://api.github.com/users/flask-restful/repos","events_url":"https://api.github.com/users/flask-restful/events{/privacy}","received_events_url":"https://api.github.com/users/flask-restful/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flask-restful/flask-restful","description":"Simple framework for creating REST APIs","fork":false,"url":"https://api.github.com/repos/flask-restful/flask-restful","forks_url":"https://api.github.com/repos/flask-restful/flask-restful/forks","keys_url":"https://api.github.com/repos/flask-restful/flask-restful/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flask-restful/flask-restful/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flask-restful/flask-restful/teams","hooks_url":"https://api.github.com/repos/flask-restful/flask-restful/hooks","issue_events_url":"https://api.github.com/repos/flask-restful/flask-restful/issues/events{/number}","events_url":"https://api.github.com/repos/flask-restful/flask-restful/events","assignees_url":"https://api.github.com/repos/flask-restful/flask-restful/assignees{/user}","branches_url":"https://api.github.com/repos/flask-restful/flask-restful/branches{/branch}","tags_url":"https://api.github.com/repos/flask-restful/flask-restful/tags","blobs_url":"https://api.github.com/repos/flask-restful/flask-restful/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flask-restful/flask-restful/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flask-restful/flask-restful/git/refs{/sha}","trees_url":"https://api.github.com/repos/flask-restful/flask-restful/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flask-restful/flask-restful/statuses/{sha}","languages_url":"https://api.github.com/repos/flask-restful/flask-restful/languages","stargazers_url":"https://api.github.com/repos/flask-restful/flask-restful/stargazers","contributors_url":"https://api.github.com/repos/flask-restful/flask-restful/contributors","subscribers_url":"https://api.github.com/repos/flask-restful/flask-restful/subscribers","subscription_url":"https://api.github.com/repos/flask-restful/flask-restful/subscription","commits_url":"https://api.github.com/repos/flask-restful/flask-restful/commits{/sha}","git_commits_url":"https://api.github.com/repos/flask-restful/flask-restful/git/commits{/sha}","comments_url":"https://api.github.com/repos/flask-restful/flask-restful/comments{/number}","issue_comment_url":"https://api.github.com/repos/flask-restful/flask-restful/issues/comments/{number}","contents_url":"https://api.github.com/repos/flask-restful/flask-restful/contents/{+path}","compare_url":"https://api.github.com/repos/flask-restful/flask-restful/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flask-restful/flask-restful/merges","archive_url":"https://api.github.com/repos/flask-restful/flask-restful/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flask-restful/flask-restful/downloads","issues_url":"https://api.github.com/repos/flask-restful/flask-restful/issues{/number}","pulls_url":"https://api.github.com/repos/flask-restful/flask-restful/pulls{/number}","milestones_url":"https://api.github.com/repos/flask-restful/flask-restful/milestones{/number}","notifications_url":"https://api.github.com/repos/flask-restful/flask-restful/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flask-restful/flask-restful/labels{/name}","releases_url":"https://api.github.com/repos/flask-restful/flask-restful/releases{/id}","created_at":"2012-10-12T00:08:51Z","updated_at":"2015-01-08T22:48:45Z","pushed_at":"2015-01-07T16:01:49Z","git_url":"git://github.com/flask-restful/flask-restful.git","ssh_url":"git@github.com:flask-restful/flask-restful.git","clone_url":"https://github.com/flask-restful/flask-restful.git","svn_url":"https://github.com/flask-restful/flask-restful","homepage":"http://flask-restful.readthedocs.org","size":2920,"stargazers_count":1159,"watchers_count":1159,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":237,"mirror_url":null,"open_issues_count":33,"forks":237,"open_issues":33,"watchers":1159,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flask-restful/flask-restful/pulls/342"},"html":{"href":"https://github.com/flask-restful/flask-restful/pull/342"},"issue":{"href":"https://api.github.com/repos/flask-restful/flask-restful/issues/342"},"comments":{"href":"https://api.github.com/repos/flask-restful/flask-restful/issues/342/comments"},"review_comments":{"href":"https://api.github.com/repos/flask-restful/flask-restful/pulls/342/comments"},"review_comment":{"href":"https://api.github.com/repos/flask-restful/flask-restful/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/flask-restful/flask-restful/pulls/342/commits"},"statuses":{"href":"https://api.github.com/repos/flask-restful/flask-restful/statuses/12ec85187fcb853b7755b4fed8b7995a9e351727"}}}}