Exception: ThinkingSphinx::SphinxError

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

Direct Known Subclasses

ConnectionError, QueryError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#statementObject

Returns the value of attribute statement



2
3
4
# File 'lib/thinking_sphinx/errors.rb', line 2

def statement
  @statement
end

Class Method Details

.new_from_mysql(error) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/thinking_sphinx/errors.rb', line 4

def self.new_from_mysql(error)
  case error.message
  when /parse error/
    replacement = ThinkingSphinx::ParseError.new(error.message)
  when /syntax error/
    replacement = ThinkingSphinx::SyntaxError.new(error.message)
  when /query error/
    replacement = ThinkingSphinx::QueryError.new(error.message)
  when /Can't connect to MySQL server/, /Communications link failure/
    replacement = ThinkingSphinx::ConnectionError.new(
      "Error connecting to Sphinx via the MySQL protocol. #{error.message}"
    )
  else
    replacement = new(error.message)
  end

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