Module: HandleExceptions::ClassMethods

Defined in:
lib/myimdb/scraper/base.rb

Instance Method Summary collapse

Instance Method Details

#handle_exceptions_for(*method_names) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/myimdb/scraper/base.rb', line 14

def handle_exceptions_for(*method_names)
  method_names.each do |method_name|
    alias_method("_#{method_name}", method_name)
    define_method(method_name) do
      begin
        send("_#{method_name}")
      rescue
        raise UnformattedHtml.new("Unable to find tag: #{method_name}, probably you are parsing the wrong page.")
      end
    end
  end
end