instance method
translate_exception
Ruby on Rails 5.2.8.1
Since v4.0.13 PrivateSignature
translate_exception(exception, message)
No documentation comment.
Parameters
-
exceptionreq -
messagereq
Source
# File activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb, line 494
def translate_exception(exception, message)
case exception.message
# SQLite 3.8.2 returns a newly formatted error message:
# UNIQUE constraint failed: *table_name*.*column_name*
# Older versions of SQLite return:
# column *column_name* is not unique
when /column(s)? .* (is|are) not unique/, /UNIQUE constraint failed: .*/
RecordNotUnique.new(message)
when /.* may not be NULL/, /NOT NULL constraint failed: .*/
NotNullViolation.new(message)
when /FOREIGN KEY constraint failed/i
InvalidForeignKey.new(message)
else
super
end
end
Defined in activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb line 494
· View on GitHub
· Improve this page
· Find usages on GitHub