A presentation at ParisRB Meetup in May 2020 in Paris, France by Sunny Ripert
https://github.com/sunny https://twitter.com/sunfox https://sunfox.org
La place de marché dédiée à l’impression 3d
https://cults3d.com
def call(order)
rescue Net::OpenTimeout, Net::ReadTimeout try_again_later(order) end
rescue Net::OpenTimeout, Net::ReadTimeout try_again_later(order) rescue Faraday::ConnectionFailed => error if error.message == “execution expired” try_again_later(order) end end
module FaradayTimeoutErrorMatcher def self.===(error) error.is_a?(Faraday::ConnectionFailed) && error.message == “execution expired” end end
rescue Net::OpenTimeout, Net::ReadTimeout, FaradayTimeoutErrorMatcher try_again_later(order) end
module NetworkTimeoutErrorMatcher def self.===(error) case error when Faraday::ConnectionFailed error.message == “execution expired” when Net::OpenTimeout, Net::ReadTimeout true end end end
rescue NetworkTimeoutErrorMatcher try_again_later(order) end
def call(order) retriable(on: NetworkTimeoutErrorMatcher) do # do something… end end
View Error matchers in Ruby on Notist.
Dismiss
Tricks to simplify exception matching in Ruby