Search code examples
ruby-on-railsrubyactiverecordtiny-tds

How to catch TinyTds::Error on Rails


I want to make things failsafe.

If the database server is down, or something goes wrong, TinyTds throws TinyTds::Error. But I can't catch that error. All I want to do is to write log for that and show an error page for user.

I've searched long time but I can't find how.


Solution

  • Problem solved. This is not controller-level issue, and thus, it is obvious that I can't catch an error which is not a controller level.

    I've solved with exception_handler gem. With that gem, I can bypass the stock middleware and customize the behavior when I got TinyTds::Error