In ruby you can catch StandardErrors using begin rescue end

begin
  #Some thing which might fails
rescue
  $stderr.puts $!
end

We can add a mnemonic variable name to the captured error using :

begin
  #Some thing which might fails
rescue => error
  $stderr.puts error
end

Other Special Ruby Variables. I am not sure on the completeness of that list so here is another and another.

For more on Ruby error handling I would recommend Avdi Grimms book Exceptional Ruby