ruby on rails - How get the error of ActiveRecord::Base.connection.execute? -
begin activerecord::base.transaction // ... sanitized_sql = "insert pinfo ..." activerecord::base.connection.execute(sanitized_sql) end rescue // how can error? end
in webrick console, error (1967-07-16?00:00:00
) shown as:
execute (0.0ms) odbc::error: 22008 (241) [unixodbc][freetds][sql server]syntax error converting datetime character string.: insert pinfo (birthdate) values ('1967-07-16?00:00:00') execute (0.8ms) if @@trancount > 0 rollback transaction
how can above error message (odbc::error: 22008 (241) ...
) raised activerecord::base.connection.execute
in rescue
?
begin activerecord::base.transaction // ... sanitized_sql = "insert pinfo ..." activerecord::base.connection.execute(sanitized_sql) end rescue exception => exc logger.error("message log file #{exc.message}") flash[:notice] = "store error message #{exec.message}" end
thanks
Comments
Post a Comment