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/548cf278 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/548cf278 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/548cf278 Branch: refs/heads/ruby-engine-apis Commit: 548cf278bb44013628614bd05f5b1d7b48d1b81a Parents: 7e51e99 Author: Darryl L. Pierce <[email protected]> Authored: Thu Feb 19 14:28:54 2015 -0500 Committer: Darryl L. Pierce <[email protected]> Committed: Mon May 18 11:33:31 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/548cf278/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: [email protected] For additional commands, e-mail: [email protected]
