{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/24060476","id":24060476,"diff_hunk":"@@ -20,7 +20,7 @@ def mysql2_connection(config)\n       ConnectionAdapters::Mysql2Adapter.new(client, logger, options, config)\n     rescue Mysql2::Error => error\n       if error.message.include?(\"Unknown database\")\n-        raise ActiveRecord::NoDatabaseError.new(error.message, error)\n+        raise ActiveRecord::NoDatabaseError.new(error.message)","path":"activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb","position":5,"original_position":5,"commit_id":"8b447f6349dac0093877c62b12601e3f26dcd7dc","original_commit_id":"8b447f6349dac0093877c62b12601e3f26dcd7dc","user":{"login":"yuki24","id":386234,"avatar_url":"https://avatars.githubusercontent.com/u/386234?v=3","gravatar_id":"","url":"https://api.github.com/users/yuki24","html_url":"https://github.com/yuki24","followers_url":"https://api.github.com/users/yuki24/followers","following_url":"https://api.github.com/users/yuki24/following{/other_user}","gists_url":"https://api.github.com/users/yuki24/gists{/gist_id}","starred_url":"https://api.github.com/users/yuki24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuki24/subscriptions","organizations_url":"https://api.github.com/users/yuki24/orgs","repos_url":"https://api.github.com/users/yuki24/repos","events_url":"https://api.github.com/users/yuki24/events{/privacy}","received_events_url":"https://api.github.com/users/yuki24/received_events","type":"User","site_admin":false},"body":"one more, `#cause` returns `nil` here. We can also do the below, but it doesn't guarantee that `ActiveRecord::NoDatabaseError` will always have the original error message.\r\n\r\n```ruby\r\nraise ActiveRecord::NoDatabaseError, error.message\r\n```","created_at":"2015-02-04T03:21:24Z","updated_at":"2015-02-04T03:21:24Z","html_url":"https://github.com/rails/rails/pull/18774#discussion_r24060476","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/18774","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/24060476"},"html":{"href":"https://github.com/rails/rails/pull/18774#discussion_r24060476"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/18774"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/18774","id":28436456,"html_url":"https://github.com/rails/rails/pull/18774","diff_url":"https://github.com/rails/rails/pull/18774.diff","patch_url":"https://github.com/rails/rails/pull/18774.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/18774","number":18774,"state":"open","locked":false,"title":"Deprecate exception#original_exception in favor of exception#cause","user":{"login":"yuki24","id":386234,"avatar_url":"https://avatars.githubusercontent.com/u/386234?v=3","gravatar_id":"","url":"https://api.github.com/users/yuki24","html_url":"https://github.com/yuki24","followers_url":"https://api.github.com/users/yuki24/followers","following_url":"https://api.github.com/users/yuki24/following{/other_user}","gists_url":"https://api.github.com/users/yuki24/gists{/gist_id}","starred_url":"https://api.github.com/users/yuki24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuki24/subscriptions","organizations_url":"https://api.github.com/users/yuki24/orgs","repos_url":"https://api.github.com/users/yuki24/repos","events_url":"https://api.github.com/users/yuki24/events{/privacy}","received_events_url":"https://api.github.com/users/yuki24/received_events","type":"User","site_admin":false},"body":"This replaces `#original_exception` with `#cause` available since Ruby 2.1.\r\n\r\nAlthough this change simplifies many exceptions, this will slightly change some of the existing behaviours as `#cause` is not the exact same thing as `#original_exception` (all exceptions automatically capture the original exception). AFAIK, there isn't a big issue internally within Rails, but for example `#rescue_from` will behave differently with `#cause`:\r\n\r\n```ruby\r\nclass SomeController < ApplicationController\r\n  # This won't catch `OtherError` with this change.\r\n  rescue_from OtherError do |error|\r\n    do_something\r\n  end\r\n\r\n  def index\r\n    begin\r\n      raise SomeError # With this change, this exception is rescued, not the last one.\r\n    rescue\r\n      raise OtherError # Right now, this exception is rescued.\r\n    end\r\n  end\r\nend\r\n```\r\n\r\nWhat we can do is to have a list of exceptions that should be replaced with `#cause` so errors like `ActionView::TemplateError` will be unwrapped properly. What do you guys think of this change?","created_at":"2015-02-01T20:23:01Z","updated_at":"2015-02-04T03:21:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8550fa7f90862db3716ab7603b3c9fb3b44cc33","assignee":null,"milestone":{"url":"https://api.github.com/repos/rails/rails/milestones/34","labels_url":"https://api.github.com/repos/rails/rails/milestones/34/labels","id":665192,"number":34,"title":"5.0.0","description":null,"creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":94,"closed_issues":56,"state":"open","created_at":"2014-05-21T00:58:22Z","updated_at":"2015-02-03T18:48:18Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/rails/rails/pulls/18774/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/18774/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments/{number}","comments_url":"https://api.github.com/repos/rails/rails/issues/18774/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/8b447f6349dac0093877c62b12601e3f26dcd7dc","head":{"label":"yuki24:deprecate-original-exception-infavor-of-cause","ref":"deprecate-original-exception-infavor-of-cause","sha":"8b447f6349dac0093877c62b12601e3f26dcd7dc","user":{"login":"yuki24","id":386234,"avatar_url":"https://avatars.githubusercontent.com/u/386234?v=3","gravatar_id":"","url":"https://api.github.com/users/yuki24","html_url":"https://github.com/yuki24","followers_url":"https://api.github.com/users/yuki24/followers","following_url":"https://api.github.com/users/yuki24/following{/other_user}","gists_url":"https://api.github.com/users/yuki24/gists{/gist_id}","starred_url":"https://api.github.com/users/yuki24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuki24/subscriptions","organizations_url":"https://api.github.com/users/yuki24/orgs","repos_url":"https://api.github.com/users/yuki24/repos","events_url":"https://api.github.com/users/yuki24/events{/privacy}","received_events_url":"https://api.github.com/users/yuki24/received_events","type":"User","site_admin":false},"repo":{"id":4546410,"name":"rails","full_name":"yuki24/rails","owner":{"login":"yuki24","id":386234,"avatar_url":"https://avatars.githubusercontent.com/u/386234?v=3","gravatar_id":"","url":"https://api.github.com/users/yuki24","html_url":"https://github.com/yuki24","followers_url":"https://api.github.com/users/yuki24/followers","following_url":"https://api.github.com/users/yuki24/following{/other_user}","gists_url":"https://api.github.com/users/yuki24/gists{/gist_id}","starred_url":"https://api.github.com/users/yuki24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuki24/subscriptions","organizations_url":"https://api.github.com/users/yuki24/orgs","repos_url":"https://api.github.com/users/yuki24/repos","events_url":"https://api.github.com/users/yuki24/events{/privacy}","received_events_url":"https://api.github.com/users/yuki24/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yuki24/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/yuki24/rails","forks_url":"https://api.github.com/repos/yuki24/rails/forks","keys_url":"https://api.github.com/repos/yuki24/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yuki24/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yuki24/rails/teams","hooks_url":"https://api.github.com/repos/yuki24/rails/hooks","issue_events_url":"https://api.github.com/repos/yuki24/rails/issues/events{/number}","events_url":"https://api.github.com/repos/yuki24/rails/events","assignees_url":"https://api.github.com/repos/yuki24/rails/assignees{/user}","branches_url":"https://api.github.com/repos/yuki24/rails/branches{/branch}","tags_url":"https://api.github.com/repos/yuki24/rails/tags","blobs_url":"https://api.github.com/repos/yuki24/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yuki24/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yuki24/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/yuki24/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yuki24/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/yuki24/rails/languages","stargazers_url":"https://api.github.com/repos/yuki24/rails/stargazers","contributors_url":"https://api.github.com/repos/yuki24/rails/contributors","subscribers_url":"https://api.github.com/repos/yuki24/rails/subscribers","subscription_url":"https://api.github.com/repos/yuki24/rails/subscription","commits_url":"https://api.github.com/repos/yuki24/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/yuki24/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/yuki24/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/yuki24/rails/issues/comments/{number}","contents_url":"https://api.github.com/repos/yuki24/rails/contents/{+path}","compare_url":"https://api.github.com/repos/yuki24/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yuki24/rails/merges","archive_url":"https://api.github.com/repos/yuki24/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yuki24/rails/downloads","issues_url":"https://api.github.com/repos/yuki24/rails/issues{/number}","pulls_url":"https://api.github.com/repos/yuki24/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/yuki24/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/yuki24/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yuki24/rails/labels{/name}","releases_url":"https://api.github.com/repos/yuki24/rails/releases{/id}","created_at":"2012-06-04T11:33:47Z","updated_at":"2015-02-02T01:03:03Z","pushed_at":"2015-02-03T13:24:53Z","git_url":"git://github.com/yuki24/rails.git","ssh_url":"git@github.com:yuki24/rails.git","clone_url":"https://github.com/yuki24/rails.git","svn_url":"https://github.com/yuki24/rails","homepage":"http://rubyonrails.org","size":127294,"stargazers_count":1,"watchers_count":1,"language":"Ruby","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":1,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"826ed62ff6bcc7bb5f91480c998cb1c04c139faf","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments/{number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-02-03T22:53:35Z","pushed_at":"2015-02-03T23:04:03Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":369295,"stargazers_count":24798,"watchers_count":24798,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9655,"mirror_url":null,"open_issues_count":772,"forks":9655,"open_issues":772,"watchers":24798,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/18774"},"html":{"href":"https://github.com/rails/rails/pull/18774"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/18774"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/18774/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/18774/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/18774/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/8b447f6349dac0093877c62b12601e3f26dcd7dc"}}}}