Caching database connection failed error

Dear Friends,

I have developed a web application in rails 3.0.7. Whenever my
application runs, if database is down, then I want to cache that error
and give message as database down to user in front end. I want to know,
how to cache this error. Please help me out of this problem. Thanks in
advance…

Thanks & Regards,
Vivek.N