Module: Sequel::ErrorSQL

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

Instance Method Summary collapse

Instance Method Details

#log_exception(exception, message) ⇒ Object

Store the SQL related to the exception with the exception, so it is available for DatabaseError#sql later.



48
49
50
51
# File 'lib/sequel/extensions/error_sql.rb', line 48

def log_exception(exception, message)
  exception.instance_variable_set(:@sequel_error_sql, message)
  super
end

#log_yield(sql, 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.



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/sequel/extensions/error_sql.rb', line 56

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