문제

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?

도움이 되었습니까?

해결책

You can do this:

rescue => e
  if Rails.env.test?
    raise
  else
    puts "Error: #{ e } at: \n#{ e.backtrace.first }"
  end
end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top