0
是否有可能在调用API时引发异常(如果有),然后退出发生异常的方法并继续正常调用其他方法?例如,在情况是这样的:API错误时退出方法并继续使用其他方法
Class1.first_method
Class2.second_method -> failed because of an API error
Clas3.third_method - I want this one to continue
是否有可能在调用API时引发异常(如果有),然后退出发生异常的方法并继续正常调用其他方法?例如,在情况是这样的:API错误时退出方法并继续使用其他方法
Class1.first_method
Class2.second_method -> failed because of an API error
Clas3.third_method - I want this one to continue
Class1.first_method
begin
Class2.second_method
rescue StandardError => e
$stderr << "An error occurred: #{e.message}"
end
Clas3.third_method
这是一个救援块,其是这样的红宝石的一部分的示例允许Exception handling