variable $ERROR_INFO

$ERROR_INFO -> Exception | nil[permalink][rdoc][edit] [added by English]

$! の別名

require "English"
class SomethingError < StandardError; end

begin
  raise SomethingError
rescue
  p $ERROR_INFO.backtrace #=> ["sample.rb:5"]
  p $ERROR_INFO.to_s #=> "SomethingError"
end