1

I have a process that is within a begin rescue loop, that looks like this:

begin
  # do some stuff
rescue Exception => e
  Rails.logger.info "#{e.response.message}"
end

Is it possible for this to NOT catch an exception? For some reason my process is running, not throwing errors, but randomly not working.

Jordan Running
  • 97,653
  • 15
  • 175
  • 173
ToddT
  • 2,662
  • 3
  • 32
  • 67

2 Answers2

1

Just use :

# do some stuff

without any begin/rescue block, and see which Error comes out. Let's say it is NoMethodError. Maybe you have a typo in some of your code, like "abc".spilt. Correct it. Try again, maybe you get Errno::ECONNRESET.

Try :

begin
  # do some stuff
rescue Errno::ECONNRESET => e
  Rails.logger.info "#{e.message}"
end

Rinse and repeat, but start from scratch. rescue Exception is just too much.

Community
  • 1
  • 1
Eric Duminil
  • 50,694
  • 8
  • 64
  • 113
0

Maybe you can temporary comment rescue block:

#begin
  ...
#rescue Exception => e
 #Rails.logger.info "#{e.response.message}"

or you can raise raise this exception in rescue:

begin
  do some stuff
rescue Exception => e
  Rails.logger.info "#{e.response.message}"
  raise e
end
sig
  • 268
  • 1
  • 10