instance method
translate_exception
Ruby on Rails 4.1.16
Since v3.0.20Signature
translate_exception(exception, message)
No documentation comment.
Parameters
-
exceptionreq -
messagereq
Source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 744
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
Defined in activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb line 744
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter