Module: ABMeter::ErrorSafety::ClassMethods
- Defined in:
- lib/abmeter/error_safety.rb
Instance Method Summary collapse
-
#error_safe(method_name) ⇒ Object
DSL method to wrap methods with error handling Usage: error_safe :method_name.
Instance Method Details
#error_safe(method_name) ⇒ Object
DSL method to wrap methods with error handling Usage: error_safe :method_name
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/abmeter/error_safety.rb', line 10 def error_safe(method_name) original_method = instance_method(method_name) define_method(method_name) do |*args, **kwargs, &block| original_method.bind(self).call(*args, **kwargs, &block) rescue StandardError => e log_error("Failed to execute #{method_name}", e) call_error_callback(e) if @config&.error_callback nil end end |