Answers for "how to use begin rescue in ruby"

1

ruby begin rescue ensure

begin
  # something which might raise an exception
rescue SomeExceptionClass => some_variable
  # code that deals with some exception
rescue SomeOtherException => some_other_variable
  # code that deals with some other exception
else
  # code that runs only if *no* exception was raised
ensure
  # ensure that this code always runs, no matter what
  # does not change the final value of the block
end
Posted by: Guest on February-08-2022
0

ruby begin rescue ensure

begin
  fire_ze_missiles
rescue
  retry #just once more for good luck
else
  log "We set up them the bomb."
ensure
  wtf_mate
end
Posted by: Guest on September-16-2020

Browse Popular Code Answers by Language