diff --git a/lib/rabbitmq/util.rb b/lib/rabbitmq/util.rb
index <HASH>..<HASH> 100644
--- a/lib/rabbitmq/util.rb
+++ b/lib/rabbitmq/util.rb
@@ -4,7 +4,8 @@ class RabbitMQ::FFI::Error < RuntimeError; end
 module RabbitMQ::Util
   class << self
     
-    def error_check rc
+    def error_check rc=nil
+      rc ||= yield
       return if rc == 0
       raise RabbitMQ::FFI::Error, RabbitMQ::FFI.amqp_error_string2(rc)
     end
diff --git a/spec/util_spec.rb b/spec/util_spec.rb
index <HASH>..<HASH> 100644
--- a/spec/util_spec.rb
+++ b/spec/util_spec.rb
@@ -13,5 +13,13 @@ describe RabbitMQ::Util do
     it "raises an error when given a nonzero result code" do
       expect { subject.error_check(-1) }.to raise_error RabbitMQ::FFI::Error
     end
+    
+    it "returns nil when given a zero result code in a block" do
+      subject.error_check { 0 }.should eq nil
+    end
+    
+    it "raises an error when given a nonzero result code in a block" do
+      expect { subject.error_check { -1 } }.to raise_error RabbitMQ::FFI::Error
+    end
   end
 end
Add block form to Util.error_check.