Exception: ThinkingSphinx::SphinxError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/thinking_sphinx/errors.rb

Direct Known Subclasses

ConnectionError, QueryError, QueryLengthError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#statementObject

Returns the value of attribute statement.



4
5
6
# File 'lib/thinking_sphinx/errors.rb', line 4

def statement
  @statement
end

Class Method Details

.new_from_mysql(error) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/thinking_sphinx/errors.rb', line 6

def self.new_from_mysql(error)
  case error.message
  when /parse error/, /query is non-computable/
    replacement = ThinkingSphinx::ParseError.new(error.message)
  when /syntax error/
    replacement = ThinkingSphinx::SyntaxError.new(error.message)
  when /query error/, /unknown column/
    replacement = ThinkingSphinx::QueryError.new(error.message)
  when /Can't connect to( MySQL)? server/,
    /Communications link failure/,
    /Lost connection to( MySQL)? server/
    replacement = ThinkingSphinx::ConnectionError.new(
      "Error connecting to Sphinx via the MySQL protocol. #{error.message}"
    )
  when /offset out of bounds/
    replacement = ThinkingSphinx::OutOfBoundsError.new(error.message)
  else
    replacement = new(error.message)
  end

  replacement.set_backtrace error.backtrace
  replacement.statement = error.statement if error.respond_to?(:statement)
  replacement
end