Question

begin
  ...
rescue => e
  puts "Error: #{ e } at: \n#{ e.backtrace.first }"
end

This works pretty well, but sometimes the error is reported to be in rack test. This makes it difficult to figure out where the error is coming from.

So, I would like to disable the rescue clause when running in the test environment.

Is this possible? Is there a better way to this?

Was it helpful?

Solution

You can do this:

rescue => e
  if Rails.env.test?
    raise
  else
    puts "Error: #{ e } at: \n#{ e.backtrace.first }"
  end
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top