Skip to content

Instantly share code, notes, and snippets.

@vemarav
Created February 7, 2018 18:23
Show Gist options
  • Save vemarav/bd14d5139ac7d55f4843e5d97e46cc13 to your computer and use it in GitHub Desktop.
Save vemarav/bd14d5139ac7d55f4843e5d97e46cc13 to your computer and use it in GitHub Desktop.
Rescue Type Error in case of wrong objects are passed as a parameter.
begin
puts "a" * 5 # => "aaaaa"
puts 1 + "" # => TypeError (string can't be coerced into Integer)
puts 5 * "a" # => Never Evaluate
rescue TypeError => e
puts e.message, e.backtrace
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment