dimanche 10 mai 2020

how to combine rescue multiple exceptions in ruby on rails?

is it possible to combine multiple rescue statements into one in ruby on rails.

begin
   //do something 
  rescue ArgumentError => e
      e.message
  rescue NameError => e
      e.message
  rescue StandardError => e
      e.message
end

combined to something like below

rescue ArgumentError, NameError, StandardError => e
      e.message

Aucun commentaire:

Enregistrer un commentaire