Forum: Ruby on Rails Catch MYSQL errors

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bcb581c41b77afce0bd1a63ce2ff1b9c?d=identicon&s=25 Serdar Kılıç (Guest)
on 2007-01-19 16:31
(Received via mailing list)
Hello,
How does one go about catching db errors, such as:

Mysql::Error in BlogController#index
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I'd rather render the error in my own layout (I do have one named
application)
--
Cheers,
Serdar Kilic
http://weblog.kilic.net/
2f9a03aa0fcfe945229cb6126eda2cb2?d=identicon&s=25 Philip Hallstrom (Guest)
on 2007-09-25 22:48
(Received via mailing list)
> Hello,
> How does one go about catching db errors, such as:
>
> Mysql::Error in BlogController#index
> Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
>
> I'd rather render the error in my own layout (I do have one named
> application)

Look at the specific exception that is being thrown and then deal with
it
in a begin/rescue/end block...

-philip
This topic is locked and can not be replied to.