method
translate_exception
v5.0.0.1 -
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 410
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)
when FOREIGN_KEY_VIOLATION
InvalidForeignKey.new(message)
when VALUE_LIMIT_VIOLATION
ValueTooLong.new(message)
else
super
end
end