eval.in

Paste #86466

Ruby — MRI 2.1, pasted 5 years ago (json)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
class Car
  def self.start
    begin
      1/0
    rescue => ex
      puts "Exception: #{ex}"
      raise StandardError.new "Can't start the car"
    end
   end
end

begin
  Car.start
rescue => ex
  puts "Cause: #{ex.cause}"
  puts "Exception: #{ex}"
end

Program Output

Exception: divided by 0
Cause: divided by 0
Exception: Can't start the car

OK (0.036 sec real, 0.043 sec wall, 9 MB, 19 syscalls)

Fork