Module: MimeActor::Rescue::ClassMethods
- Defined in:
- lib/mime_actor/rescue.rb
Instance Method Summary collapse
-
#rescue_act_from(*klazzes, action: nil, format: nil, with: nil, &block) ⇒ Object
Registers a rescue handler for the given error classes with ‘action`/`format` filter.
Instance Method Details
#rescue_act_from(*klazzes, action: nil, format: nil, with: nil, &block) ⇒ Object
Registers a rescue handler for the given error classes with ‘action`/`format` filter
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/mime_actor/rescue.rb', line 46 def rescue_act_from(*klazzes, action: nil, format: nil, with: nil, &block) raise ArgumentError, "error filter is required" if klazzes.empty? raise ArgumentError, "provide either with: or a block" unless !with.nil? ^ block_given? validate!(:callable, with) unless with.nil? with = block if block_given? validate!(:action_or_actions, action) unless action.nil? validate!(:format_or_formats, format) unless format.nil? klazzes.each do |klazz| validate!(:klazz, klazz) error = klazz.is_a?(Module) ? klazz.name : klazz # append at the end because strategies are read in reverse. actor_rescuers << [error, format, action, with] end end |