diff --git a/spec/pg/connection_spec.cr b/spec/pg/connection_spec.cr index 3dedb40d..2a8caa3a 100644 --- a/spec/pg/connection_spec.cr +++ b/spec/pg/connection_spec.cr @@ -2,7 +2,7 @@ require "../spec_helper" describe PG::Connection, "#initialize" do it "raises on bad connections" do - expect_raises(DB::ConnectionRefused) { + expect_raises(DB::ConnectionRefused, "Cannot establish connection") { DB.open("postgres://localhost:5433") } end diff --git a/src/pg/connection.cr b/src/pg/connection.cr index 75b3cdda..b1ffc9ff 100644 --- a/src/pg/connection.cr +++ b/src/pg/connection.cr @@ -13,7 +13,7 @@ module PG @connection = PQ::Connection.new(conn_info) @connection.connect rescue ex - raise DB::ConnectionRefused.new(cause: ex) + raise DB::ConnectionRefused.new(ex.message, cause: ex) end end