Exception: Vertica::Error::QueryError

Inherits:
Vertica::Error show all
Defined in:
lib/vertica/error.rb

Constant Summary

Constants inherited from Vertica::Error

QUERY_ERROR_CLASSES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_response, sql) ⇒ QueryError

Returns a new instance of QueryError.



26
27
28
29
30
# File 'lib/vertica/error.rb', line 26

def initialize(error_response, sql)
  @error_response, @sql = error_response, sql
  utf8_encoded_error = error_response.error_message.encode('utf-8', :invalid => :replace, :undef => :replace)
  super("#{utf8_encoded_error}, SQL: #{one_line_sql.inspect}" )
end

Instance Attribute Details

#error_responseObject (readonly)

Returns the value of attribute error_response.



24
25
26
# File 'lib/vertica/error.rb', line 24

def error_response
  @error_response
end

#sqlObject (readonly)

Returns the value of attribute sql.



24
25
26
# File 'lib/vertica/error.rb', line 24

def sql
  @sql
end

Class Method Details

.from_error_response(error_response, sql) ⇒ Object



36
37
38
39
# File 'lib/vertica/error.rb', line 36

def self.from_error_response(error_response, sql)
  klass = QUERY_ERROR_CLASSES[error_response.sqlstate] || self
  klass.new(error_response, sql)
end

Instance Method Details

#one_line_sqlObject



32
33
34
# File 'lib/vertica/error.rb', line 32

def one_line_sql
  @sql.to_s.encode('utf-8', :invalid => :replace, :undef => :replace).gsub(/[\r\n]+/, ' ')
end