救援URI :: InvalidURIError

时间:2016-07-14 09:53:57

标签: ruby-on-rails ruby exception-handling

为什么我的rescue没有从例外中解救?

错误

    2016-07-14T09:43:06.062Z 6490 TID-ox0hrishg WARN: URI::InvalidURIError: bad URI(is not URI?): 
2016-07-14T09:43:06.062Z 6490 TID-ox0hrishg WARN: /Users/stas/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/uri/rfc3986_parser.rb:18:in `rescue in split'



  begin
   xml_loop(@xml.products)
  rescue URI::InvalidURIError
    index = @xml.get_index(XmlTracker.last.xml_id)
    xml_loop(@xml.products[index...900])
 else
 ....
end

如何处理?

1 个答案:

答案 0 :(得分:1)

您忘记将end块放入begin

  begin
    xml_loop(@xml.products)
  rescue URI::InvalidURIError
    index = @xml.get_index(XmlTracker.last.xml_id)
    xml_loop(@xml.products[index...900])
  end