lib/agcod/create_gift_card.rb in agcod-0.0.2 vs lib/agcod/create_gift_card.rb in agcod-0.0.3
- old
+ new
@@ -54,11 +54,12 @@
ActiveResource::TimeoutError,
Errno::ECONNREFUSED,
Errno::EHOSTDOWN,
Errno::EHOSTUNREACH
- attempt_to_void
+ sleep(15)
+ attempt_to_void_with_retry
end
end
def attempt_retry
#check for retry error
@@ -80,9 +81,23 @@
@resend_void_sent = true
attempt_to_void
end
end
+ def attempt_to_void_with_retry
+ begin
+ attempt_to_void
+ rescue SocketError,
+ Timeout::Error,
+ ActiveResource::TimeoutError,
+ Errno::ECONNREFUSED,
+ Errno::EHOSTDOWN,
+ Errno::EHOSTUNREACH
+ sleep(15)
+ attempt_to_void
+ end
+ end
+
def attempt_to_void
Agcod::VoidGiftCardCreation.new("request_id" => self.request_id).submit
end
end