0

How do I do error handling with something like this in RoR:

conn = Person.connection
conn.execute(sql_stmt)

What if there were errors while executing the SQL?

1 Answer 1

1

The execute method is just a wrapper for the connection's query method and that will raise an Mysql::Error exception if something is wrong. If you use mysql2 instead of the older mysql gem, then I think you'll get a Mysql2::Error exception.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.