Currently, an active recording replaces the original error with an internal one, without transmitting the original with a new error. I canβt understand why anyone would like this.
So, the only solution right now is the monkey patch;)
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
def translate_exception(e, message)
ActiveRecord::WrappedDatabaseException.new(message,e)
end
end
end
end
_.
def self.validate_email(systemuserid, emailaddress)
begin
result = (self.find_by_sql(["SELECT fn_systemuser_validate_email(?, ?) AS returncode", systemuserid, emailaddress])).first
rescue ActiveRecord::WrappedDatabaseException => e
pgerror = e.original_exception
puts "Doing my stuff: #{pgerror.result.result_error_message}"
end
end
pg 0.11 Rails 3.0.9. , .