Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

296
Views
How to rescue an exception from inside a rescue
def func 
   some code...
   rescue x,y,z
      do something...

I have a function where I'm trying to rescue an exception and then do something inside of rescue. I want to understand how to handle in case there is an exception again inside of the rescue block. This is a corner case and it is definitely necessary.

In case there is an exception again inside of rescue I want to be able to handle it. Any suggestions appreciated.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can simply nest a rescue exception inside another rescue exception and you can do so using a number of different approaches depending on the situation but here are a couple:

begin

  do_something

rescue

  do_something_else rescue do_this_instead

end

OR

begin

  do_something

rescue

  begin
    do_something_else
  rescue
    do_this_instead
  end

end
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!