Skip to content

Instantly share code, notes, and snippets.

@JonZso
Created May 8, 2019 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonZso/a574e328a9b87af1861308c0a8321373 to your computer and use it in GitHub Desktop.
Save JonZso/a574e328a9b87af1861308c0a8321373 to your computer and use it in GitHub Desktop.
begin
retries ||= 0
puts "trying to check if file exists.."
sleep(4)
file = File.read("file2.json")
raise "Files doesn't exist"
rescue
retry if (retries += 1) < 3 and !File.file?("file2.json")
if retries == 3
file = "File Not Found."
end
end
puts file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment