{"action":"created","comment":{"url":"https://api.github.com/repos/bellycard/napa_rails/pulls/comments/71423605","id":71423605,"diff_hunk":"@@ -0,0 +1,32 @@\n+if defined?(Rails)\n+  module Napa\n+    module GrapeExtenders\n+      def self.extended(modified_class)\n+        # when extended, set the exceptions to handle\n+\n+        # if AR is being used, rescue from common AR errors\n+        if defined?(::ActiveRecord)\n+          modified_class.rescue_from ::ActiveRecord::RecordNotFound do\n+            err = Napa::JsonError.new(:record_not_found, 'record not found')\n+            Rails.logger.debug({ status: 404, headers: {}, response: err.try(:first) }.map { |k, v| \"#{k}=#{v}\" }.join(' '))\n+            rack_response(err.to_json, 404)\n+          end\n+          modified_class.rescue_from ::ActiveRecord::RecordInvalid do |e|\n+            err = Napa::JsonError.new(:unprocessable_entity, e.message, e.record.errors.messages)\n+            Rails.logger.debug({ status: 422, headers: {}, response: err.try(:first) }.map { |k, v| \"#{k}=#{v}\" }.join(' '))\n+            rack_response(err.to_json, 422)\n+          end\n+        end\n+\n+        # if AASM is being used, rescue from invalid transitions\n+        if defined?(::AASM)\n+          modified_class.rescue_from ::AASM::InvalidTransition do |e|\n+            err = Napa::JsonError.new(:unprocessable_entity, e.message)\n+            Rails.logger.debug({ status: 422, headers: {}, response: err.try(:first) }.map { |k, v| \"#{k}=#{v}\" }.join(' '))","path":"lib/napa/grape_extensions/grape_extenders.rb","position":25,"original_position":25,"commit_id":"b45c728bb5578429eb246bd58ce48e3d90bb9a3f","original_commit_id":"b45c728bb5578429eb246bd58ce48e3d90bb9a3f","user":{"login":"fgv02009","id":8260388,"avatar_url":"https://avatars.githubusercontent.com/u/8260388?v=3","gravatar_id":"","url":"https://api.github.com/users/fgv02009","html_url":"https://github.com/fgv02009","followers_url":"https://api.github.com/users/fgv02009/followers","following_url":"https://api.github.com/users/fgv02009/following{/other_user}","gists_url":"https://api.github.com/users/fgv02009/gists{/gist_id}","starred_url":"https://api.github.com/users/fgv02009/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgv02009/subscriptions","organizations_url":"https://api.github.com/users/fgv02009/orgs","repos_url":"https://api.github.com/users/fgv02009/repos","events_url":"https://api.github.com/users/fgv02009/events{/privacy}","received_events_url":"https://api.github.com/users/fgv02009/received_events","type":"User","site_admin":false},"body":"Talked to yumin about this offline. Not as east as it seems as `self` here is actually a `Grape::Middleware::Error` going to leave as is.","created_at":"2016-07-19T21:07:26Z","updated_at":"2016-07-19T21:07:26Z","html_url":"https://github.com/bellycard/napa_rails/pull/4#discussion_r71423605","pull_request_url":"https://api.github.com/repos/bellycard/napa_rails/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/bellycard/napa_rails/pulls/comments/71423605"},"html":{"href":"https://github.com/bellycard/napa_rails/pull/4#discussion_r71423605"},"pull_request":{"href":"https://api.github.com/repos/bellycard/napa_rails/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/bellycard/napa_rails/pulls/4","id":78022769,"html_url":"https://github.com/bellycard/napa_rails/pull/4","diff_url":"https://github.com/bellycard/napa_rails/pull/4.diff","patch_url":"https://github.com/bellycard/napa_rails/pull/4.patch","issue_url":"https://api.github.com/repos/bellycard/napa_rails/issues/4","number":4,"state":"open","locked":false,"title":"add grape_extenders","user":{"login":"fgv02009","id":8260388,"avatar_url":"https://avatars.githubusercontent.com/u/8260388?v=3","gravatar_id":"","url":"https://api.github.com/users/fgv02009","html_url":"https://github.com/fgv02009","followers_url":"https://api.github.com/users/fgv02009/followers","following_url":"https://api.github.com/users/fgv02009/following{/other_user}","gists_url":"https://api.github.com/users/fgv02009/gists{/gist_id}","starred_url":"https://api.github.com/users/fgv02009/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgv02009/subscriptions","organizations_url":"https://api.github.com/users/fgv02009/orgs","repos_url":"https://api.github.com/users/fgv02009/repos","events_url":"https://api.github.com/users/fgv02009/events{/privacy}","received_events_url":"https://api.github.com/users/fgv02009/received_events","type":"User","site_admin":false},"body":"@bellycard/platform \r\n\r\nrelated discussion: https://github.com/bellycard/core-service/pull/32","created_at":"2016-07-19T18:10:46Z","updated_at":"2016-07-19T21:07:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"31aa6c66cde01d359fa0b60ca3968a2302e2ae5a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bellycard/napa_rails/pulls/4/commits","review_comments_url":"https://api.github.com/repos/bellycard/napa_rails/pulls/4/comments","review_comment_url":"https://api.github.com/repos/bellycard/napa_rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bellycard/napa_rails/issues/4/comments","statuses_url":"https://api.github.com/repos/bellycard/napa_rails/statuses/b45c728bb5578429eb246bd58ce48e3d90bb9a3f","head":{"label":"fgv02009:add-grape-extenders","ref":"add-grape-extenders","sha":"b45c728bb5578429eb246bd58ce48e3d90bb9a3f","user":{"login":"fgv02009","id":8260388,"avatar_url":"https://avatars.githubusercontent.com/u/8260388?v=3","gravatar_id":"","url":"https://api.github.com/users/fgv02009","html_url":"https://github.com/fgv02009","followers_url":"https://api.github.com/users/fgv02009/followers","following_url":"https://api.github.com/users/fgv02009/following{/other_user}","gists_url":"https://api.github.com/users/fgv02009/gists{/gist_id}","starred_url":"https://api.github.com/users/fgv02009/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgv02009/subscriptions","organizations_url":"https://api.github.com/users/fgv02009/orgs","repos_url":"https://api.github.com/users/fgv02009/repos","events_url":"https://api.github.com/users/fgv02009/events{/privacy}","received_events_url":"https://api.github.com/users/fgv02009/received_events","type":"User","site_admin":false},"repo":{"id":56004554,"name":"napa_rails","full_name":"fgv02009/napa_rails","owner":{"login":"fgv02009","id":8260388,"avatar_url":"https://avatars.githubusercontent.com/u/8260388?v=3","gravatar_id":"","url":"https://api.github.com/users/fgv02009","html_url":"https://github.com/fgv02009","followers_url":"https://api.github.com/users/fgv02009/followers","following_url":"https://api.github.com/users/fgv02009/following{/other_user}","gists_url":"https://api.github.com/users/fgv02009/gists{/gist_id}","starred_url":"https://api.github.com/users/fgv02009/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgv02009/subscriptions","organizations_url":"https://api.github.com/users/fgv02009/orgs","repos_url":"https://api.github.com/users/fgv02009/repos","events_url":"https://api.github.com/users/fgv02009/events{/privacy}","received_events_url":"https://api.github.com/users/fgv02009/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fgv02009/napa_rails","description":"","fork":true,"url":"https://api.github.com/repos/fgv02009/napa_rails","forks_url":"https://api.github.com/repos/fgv02009/napa_rails/forks","keys_url":"https://api.github.com/repos/fgv02009/napa_rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fgv02009/napa_rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fgv02009/napa_rails/teams","hooks_url":"https://api.github.com/repos/fgv02009/napa_rails/hooks","issue_events_url":"https://api.github.com/repos/fgv02009/napa_rails/issues/events{/number}","events_url":"https://api.github.com/repos/fgv02009/napa_rails/events","assignees_url":"https://api.github.com/repos/fgv02009/napa_rails/assignees{/user}","branches_url":"https://api.github.com/repos/fgv02009/napa_rails/branches{/branch}","tags_url":"https://api.github.com/repos/fgv02009/napa_rails/tags","blobs_url":"https://api.github.com/repos/fgv02009/napa_rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fgv02009/napa_rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fgv02009/napa_rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/fgv02009/napa_rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fgv02009/napa_rails/statuses/{sha}","languages_url":"https://api.github.com/repos/fgv02009/napa_rails/languages","stargazers_url":"https://api.github.com/repos/fgv02009/napa_rails/stargazers","contributors_url":"https://api.github.com/repos/fgv02009/napa_rails/contributors","subscribers_url":"https://api.github.com/repos/fgv02009/napa_rails/subscribers","subscription_url":"https://api.github.com/repos/fgv02009/napa_rails/subscription","commits_url":"https://api.github.com/repos/fgv02009/napa_rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/fgv02009/napa_rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/fgv02009/napa_rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/fgv02009/napa_rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/fgv02009/napa_rails/contents/{+path}","compare_url":"https://api.github.com/repos/fgv02009/napa_rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fgv02009/napa_rails/merges","archive_url":"https://api.github.com/repos/fgv02009/napa_rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fgv02009/napa_rails/downloads","issues_url":"https://api.github.com/repos/fgv02009/napa_rails/issues{/number}","pulls_url":"https://api.github.com/repos/fgv02009/napa_rails/pulls{/number}","milestones_url":"https://api.github.com/repos/fgv02009/napa_rails/milestones{/number}","notifications_url":"https://api.github.com/repos/fgv02009/napa_rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fgv02009/napa_rails/labels{/name}","releases_url":"https://api.github.com/repos/fgv02009/napa_rails/releases{/id}","deployments_url":"https://api.github.com/repos/fgv02009/napa_rails/deployments","created_at":"2016-04-11T20:16:29Z","updated_at":"2016-04-11T20:16:30Z","pushed_at":"2016-07-19T18:35:38Z","git_url":"git://github.com/fgv02009/napa_rails.git","ssh_url":"git@github.com:fgv02009/napa_rails.git","clone_url":"https://github.com/fgv02009/napa_rails.git","svn_url":"https://github.com/fgv02009/napa_rails","homepage":null,"size":22,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"bellycard:master","ref":"master","sha":"b1ca2682559b09dbeb17d0ad6d1fc46f077e6610","user":{"login":"bellycard","id":1090217,"avatar_url":"https://avatars.githubusercontent.com/u/1090217?v=3","gravatar_id":"","url":"https://api.github.com/users/bellycard","html_url":"https://github.com/bellycard","followers_url":"https://api.github.com/users/bellycard/followers","following_url":"https://api.github.com/users/bellycard/following{/other_user}","gists_url":"https://api.github.com/users/bellycard/gists{/gist_id}","starred_url":"https://api.github.com/users/bellycard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bellycard/subscriptions","organizations_url":"https://api.github.com/users/bellycard/orgs","repos_url":"https://api.github.com/users/bellycard/repos","events_url":"https://api.github.com/users/bellycard/events{/privacy}","received_events_url":"https://api.github.com/users/bellycard/received_events","type":"Organization","site_admin":false},"repo":{"id":56004484,"name":"napa_rails","full_name":"bellycard/napa_rails","owner":{"login":"bellycard","id":1090217,"avatar_url":"https://avatars.githubusercontent.com/u/1090217?v=3","gravatar_id":"","url":"https://api.github.com/users/bellycard","html_url":"https://github.com/bellycard","followers_url":"https://api.github.com/users/bellycard/followers","following_url":"https://api.github.com/users/bellycard/following{/other_user}","gists_url":"https://api.github.com/users/bellycard/gists{/gist_id}","starred_url":"https://api.github.com/users/bellycard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bellycard/subscriptions","organizations_url":"https://api.github.com/users/bellycard/orgs","repos_url":"https://api.github.com/users/bellycard/repos","events_url":"https://api.github.com/users/bellycard/events{/privacy}","received_events_url":"https://api.github.com/users/bellycard/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bellycard/napa_rails","description":"","fork":false,"url":"https://api.github.com/repos/bellycard/napa_rails","forks_url":"https://api.github.com/repos/bellycard/napa_rails/forks","keys_url":"https://api.github.com/repos/bellycard/napa_rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bellycard/napa_rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bellycard/napa_rails/teams","hooks_url":"https://api.github.com/repos/bellycard/napa_rails/hooks","issue_events_url":"https://api.github.com/repos/bellycard/napa_rails/issues/events{/number}","events_url":"https://api.github.com/repos/bellycard/napa_rails/events","assignees_url":"https://api.github.com/repos/bellycard/napa_rails/assignees{/user}","branches_url":"https://api.github.com/repos/bellycard/napa_rails/branches{/branch}","tags_url":"https://api.github.com/repos/bellycard/napa_rails/tags","blobs_url":"https://api.github.com/repos/bellycard/napa_rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bellycard/napa_rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bellycard/napa_rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/bellycard/napa_rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bellycard/napa_rails/statuses/{sha}","languages_url":"https://api.github.com/repos/bellycard/napa_rails/languages","stargazers_url":"https://api.github.com/repos/bellycard/napa_rails/stargazers","contributors_url":"https://api.github.com/repos/bellycard/napa_rails/contributors","subscribers_url":"https://api.github.com/repos/bellycard/napa_rails/subscribers","subscription_url":"https://api.github.com/repos/bellycard/napa_rails/subscription","commits_url":"https://api.github.com/repos/bellycard/napa_rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/bellycard/napa_rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/bellycard/napa_rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/bellycard/napa_rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/bellycard/napa_rails/contents/{+path}","compare_url":"https://api.github.com/repos/bellycard/napa_rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bellycard/napa_rails/merges","archive_url":"https://api.github.com/repos/bellycard/napa_rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bellycard/napa_rails/downloads","issues_url":"https://api.github.com/repos/bellycard/napa_rails/issues{/number}","pulls_url":"https://api.github.com/repos/bellycard/napa_rails/pulls{/number}","milestones_url":"https://api.github.com/repos/bellycard/napa_rails/milestones{/number}","notifications_url":"https://api.github.com/repos/bellycard/napa_rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bellycard/napa_rails/labels{/name}","releases_url":"https://api.github.com/repos/bellycard/napa_rails/releases{/id}","deployments_url":"https://api.github.com/repos/bellycard/napa_rails/deployments","created_at":"2016-04-11T20:15:29Z","updated_at":"2016-04-11T20:16:10Z","pushed_at":"2016-07-19T18:35:39Z","git_url":"git://github.com/bellycard/napa_rails.git","ssh_url":"git@github.com:bellycard/napa_rails.git","clone_url":"https://github.com/bellycard/napa_rails.git","svn_url":"https://github.com/bellycard/napa_rails","homepage":null,"size":23,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bellycard/napa_rails/pulls/4"},"html":{"href":"https://github.com/bellycard/napa_rails/pull/4"},"issue":{"href":"https://api.github.com/repos/bellycard/napa_rails/issues/4"},"comments":{"href":"https://api.github.com/repos/bellycard/napa_rails/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/bellycard/napa_rails/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/bellycard/napa_rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bellycard/napa_rails/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/bellycard/napa_rails/statuses/b45c728bb5578429eb246bd58ce48e3d90bb9a3f"}}}}
{"actor":{"display_login":"fgv02009"}}