Method: Sequel::ErrorSQL#log_connection_yield

Defined in:
lib/sequel/extensions/error_sql.rb

#log_connection_yield(sql, conn, args = nil) ⇒ Object

If there are no loggers for this database and an exception is raised store the SQL related to the exception with the exception, so it is available for DatabaseError#sql later.



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sequel/extensions/error_sql.rb', line 60

def log_connection_yield(sql, conn, args=nil)
  if @loggers.empty?
    begin
      yield
    rescue => e
      sql = "#{connection_info(conn) if conn && log_connection_info}#{sql}#{"; #{args.inspect}" if args}"
      e.instance_variable_set(:@sequel_error_sql, sql)
      raise
    end
  else
    super
  end
end