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
  • 102,619
  • 17
  • 182
  • 182
ToddT
  • 3,084
  • 4
  • 39
  • 83

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
  • 52,989
  • 9
  • 71
  • 124
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
  • 267
  • 1
  • 10