From 3ead78ee38be40f49259c0c7960c4ba5b8eed047 Mon Sep 17 00:00:00 2001 From: Pascal Betz Date: Tue, 6 Oct 2020 21:10:21 +0200 Subject: [PATCH] add exception message https://github.com/will/crystal-pg/issues/208 --- spec/pg/connection_spec.cr | 2 +- src/pg/connection.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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