PROTON-799: Adjusted the Ruby error macro

Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f5d94237
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f5d94237
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f5d94237

Branch: refs/heads/ruby-engine-apis
Commit: f5d942373c1c3ab228fe1571a5349817f0b2b074
Parents: 76cdf32
Author: Darryl L. Pierce <mcpie...@gmail.com>
Authored: Thu Feb 19 14:28:54 2015 -0500
Committer: Darryl L. Pierce <mcpie...@gmail.com>
Committed: Tue May 19 08:03:54 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/ruby/lib/util/error_handler.rb | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f5d94237/proton-c/bindings/ruby/lib/util/error_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/error_handler.rb 
b/proton-c/bindings/ruby/lib/util/error_handler.rb
index 2f43609..da51214 100644
--- a/proton-c/bindings/ruby/lib/util/error_handler.rb
+++ b/proton-c/bindings/ruby/lib/util/error_handler.rb
@@ -41,7 +41,9 @@ module Qpid::Proton::Util
       end
     end
 
-    def can_raise_error(method_names, error_class = nil)
+    def can_raise_error(method_names, options = {})
+      error_class = options[:error_class]
+      below = options[:below] || 0
       # coerce the names to be an array
       Array(method_names).each do |method_name|
         # if the method doesn't already exist then queue this aliasing
@@ -49,12 +51,12 @@ module Qpid::Proton::Util
           @@to_be_wrapped ||= []
           @@to_be_wrapped << method_name
         else
-          create_exception_handler_wrapper(method_name, error_class)
+          create_exception_handler_wrapper(method_name, error_class, below)
         end
       end
     end
 
-    def create_exception_handler_wrapper(method_name, error_class = nil)
+    def create_exception_handler_wrapper(method_name, error_class = nil, below 
= 0)
       original_method_name = method_name.to_s
       wrapped_method_name = "_excwrap_#{original_method_name}"
       alias_method wrapped_method_name, original_method_name
@@ -63,7 +65,8 @@ module Qpid::Proton::Util
         # calls to Class.send interfere with Messenger.send
         method = self.method(wrapped_method_name.to_sym)
         rc = method.call(*args, &block)
-        check_for_error(rc, error_class)
+        check_for_error(rc, error_class) if rc < below
+        return rc
       end
     end
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to