开发者

Does a rollback still occur if I use begin...rescue and an error occurs?

I've got some strange errors happening in my rails app and I'm trying to log better errors instead of the whole stack of passenger stuff that开发者_开发百科 I don't care about. I thought I would do this with a Rescue clause and explicit error handling, like logging the params hash. But I'm concerned if this would interrupt any rollback that is happening. For that matter, I'm assuming rollbacks automatically occur when an error occurs as part of the normal rails error handling, but I haven't been able to find that documented anywhere. I'm using Dreamhost with MySQL, so I thought transactions and rollbacks were happening there.


This is not very advisable (to put a big begin-rescue on your code).

Why don't you use backtrace silencers? (from Rails 2.3) http://afreshcup.com/home/2008/11/29/rails-23-backtrace-silencing.html.

From release notes:

Rails automatically adds silencers to get rid of the most common noise in a new application, and builds a config/backtrace_silencers.rb file to hold your own additions

If you use an earlier version of Rails, use http://github.com/thoughtbot/quietbacktrace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜