【问题标题】:Rescue URI::InvalidURIError救援 URI::InvalidURIError
【发布时间】:2016-07-14 09:53:56
【问题描述】:

为什么我的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

如何处理?

【问题讨论】:

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


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-24
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 2015-07-02
      • 2012-02-26
      相关资源
      最近更新 更多