module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::TranslateException
Extend ActiveRecord::ConnectionAdapter::PostgreSQLAdapter logic to wrap more pg-specific errors into specific exception classes
Constants
- INSUFFICIENT_PRIVILEGE
See www.postgresql.org/docs/9.1/static/errcodes-appendix.html
Public Instance Methods
translate_exception(exception, message)
click to toggle source
Intercept insufficient privilege PG::Error and raise active_record wrapped database exception
Calls superclass method
# File lib/pg_saurus/connection_adapters/postgresql_adapter/translate_exception.rb, line 8 def translate_exception(exception, message) exception_result = exception.result case exception_result.try(:error_field, PG::Result::PG_DIAG_SQLSTATE) when INSUFFICIENT_PRIVILEGE exc_message = exception_result.try(:error_field, PG::Result::PG_DIAG_MESSAGE_PRIMARY) exc_message ||= message ::ActiveRecord::InsufficientPrivilege.new(exc_message) else super end end