class SQLite3::Exception

Attributes

code[R]

A convenience for accessing the error code for this exception.

sql[R]

If the error is associated with a SQL query, this is the query

sql_offset[R]

If the error is associated with a particular offset in a SQL query, this is the non-negative offset. If the offset is not available, this will be -1.

Public Instance Methods

message() click to toggle source
Calls superclass method
# File lib/sqlite3/errors.rb, line 15
def message
  [super, sql_error].compact.join(":\n")
end

Private Instance Methods

sql_error() click to toggle source
# File lib/sqlite3/errors.rb, line 19
        def sql_error
  return nil unless @sql
  return @sql.chomp unless @sql_offset >= 0

  offset = @sql_offset
  sql.lines.flat_map do |line|
    if offset >= 0 && line.length > offset
      blanks = " " * offset
      offset = -1
      [line.chomp, blanks + "^"]
    else
      offset -= line.length if offset
      line.chomp
    end
  end.join("\n")
end