Ruby How to know what to rescue?

霸气de小男生 提交于 2019-12-24 04:39:04

问题


I'm using eurovat gem to check a VAT number.

Eurovat.check_vat_number vat_number

If I run that from irb, sometimes I receive this:

SOAP::FaultError: MS_UNAVAILABLE
        from

(Nothing appear after "from")

I want to write a begin rescue block to rescue those error, but how I do know what to rescue?

I have tried with rescue SOAP::FaultError but didn't works


回答1:


I found the way after a bit of testing:

rescue SOAP::FaultError => e
    if e.message == "MS_UNAVAILABLE"
      # @ToDO handle service unavailable exception
    end
end



回答2:


Ran into a similar issue. This might be of use to you:

MS_UNAVAILABLE means that: "The Member State service is unavailable, try again later or with another Member State".



来源:https://stackoverflow.com/questions/29856485/ruby-how-to-know-what-to-rescue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!