Skip to content

Instantly share code, notes, and snippets.

@louishuyng
Created June 20, 2023 04:29
Show Gist options
  • Save louishuyng/f75beecdfd8e9de4cd86cbfd3f4cdbdb to your computer and use it in GitHub Desktop.
Save louishuyng/f75beecdfd8e9de4cd86cbfd3f4cdbdb to your computer and use it in GitHub Desktop.
Handling timeout error
require 'timeout'
begin
status = Timeout::timeout(5) {
# Something that should be interrupted if it takes too much time...
}
rescue Timeout::Error
puts 'That took too long, exiting...'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment