diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index d70ec202061d5dec0dfad72057ecbda738c00e73..e2a98e9fcd03f733b3620cbb29745b105a5b67b7 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added more informative exceptions in establish_connection #356 [bitsweat] + * Fixed that options[:counter_sql] was overwritten with interpolated sql rather than original sql #355 [bitsweat] * Fixed that overriding an attribute's accessor would be disregarded by add_on_empty and add_on_boundary_breaking because they simply used diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index d41356ffa43d30d519977ce16f936541ba65bb88..a2fb480b8ca31bfd89689ce50663d0262c1564a3 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -86,14 +86,13 @@ def self.establish_connection(spec = nil) if configuration = configurations[spec.to_s] establish_connection(configuration) else - raise AdapterNotSpecified + raise AdapterNotSpecified, "#{spec} database is not configured" end else spec = symbolize_strings_in_hash(spec) - unless spec.key?(:adapter) then raise AdapterNotSpecified end - + unless spec.key?(:adapter) then raise AdapterNotSpecified, "database configuration does not specify adapter" end adapter_method = "#{spec[:adapter]}_connection" - unless respond_to?(adapter_method) then raise AdapterNotFound end + unless respond_to?(adapter_method) then raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter" end remove_connection establish_connection(ConnectionSpecification.new(spec, adapter_method)) end