method
translate_exception
v4.2.7 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
translate_exception(exception, message)protected
No documentation available.
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 414
def translate_exception(exception, message)
return exception unless exception.respond_to?(:result)
case exception.result.try(:error_field, PGresult::PG_DIAG_SQLSTATE)
when UNIQUE_VIOLATION
RecordNotUnique.new(message, exception)
when FOREIGN_KEY_VIOLATION
InvalidForeignKey.new(message, exception)
else
super
end
end