aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-01-25 10:56:00 -0500
committerGitHub <noreply@github.com>2019-01-25 10:56:00 -0500
commitbf3a8a0e6ce13b7db50abe5288d2cc74c2e8975e (patch)
tree090b5721eebfce7012be7aadde5da41abeacf438 /activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
parent826e34be226cbb61c28867617e1e37e20beae18f (diff)
parent1284f826cc2bba6edf956b581245c2d88e576056 (diff)
downloadrails-bf3a8a0e6ce13b7db50abe5288d2cc74c2e8975e.tar.gz
rails-bf3a8a0e6ce13b7db50abe5288d2cc74c2e8975e.tar.bz2
rails-bf3a8a0e6ce13b7db50abe5288d2cc74c2e8975e.zip
Merge pull request #35042 from eileencodes/fix-error-message-for-missing-handler
Fix error raised when handler doesn't exist
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 99934a0e31..c8d5f679a8 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -1006,7 +1006,16 @@ module ActiveRecord
# for (not necessarily the current class).
def retrieve_connection(spec_name) #:nodoc:
pool = retrieve_connection_pool(spec_name)
- raise ConnectionNotEstablished, "No connection pool with '#{spec_name}' found." unless pool
+
+ unless pool
+ # multiple database application
+ if ActiveRecord::Base.connection_handler != ActiveRecord::Base.default_connection_handler
+ raise ConnectionNotEstablished, "No connection pool with '#{spec_name}' found for the '#{ActiveRecord::Base.current_role}' role."
+ else
+ raise ConnectionNotEstablished, "No connection pool with '#{spec_name}' found."
+ end
+ end
+
pool.connection
end