From 154685b1b3a1a21dfe26d9069ede7bf5ebedb501 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Tue, 21 Jun 2022 15:58:35 +0200 Subject: [PATCH] Allow PG::Error to be created without arguments Not used in our code, but some users do this and it used to work in pg<1.4.0. Fixes #466 --- lib/pg/exceptions.rb | 2 +- spec/pg_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pg/exceptions.rb b/lib/pg/exceptions.rb index 1366dc791..8940ce7c3 100644 --- a/lib/pg/exceptions.rb +++ b/lib/pg/exceptions.rb @@ -7,7 +7,7 @@ module PG class Error < StandardError - def initialize(msg, connection: nil, result: nil) + def initialize(msg=nil, connection: nil, result: nil) @connection = connection @result = result super(msg) diff --git a/spec/pg_spec.rb b/spec/pg_spec.rb index 7e3b34e18..3c9d67ca2 100644 --- a/spec/pg_spec.rb +++ b/spec/pg_spec.rb @@ -53,6 +53,10 @@ ]) end + it "can be used to raise errors without text" do + expect{ raise PG::InvalidTextRepresentation }.to raise_error(PG::InvalidTextRepresentation) + end + it "tells about the libpq library path" do expect( PG::POSTGRESQL_LIB_PATH ).to include("/") end