Exception: ClickhouseRuby::QueryError

Inherits:
Error
  • Object
show all
Defined in:
lib/clickhouse_ruby/errors.rb

Overview

Query execution errors Raised when there are issues executing a query

Instance Attribute Summary collapse

Attributes inherited from Error

#original_error

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, code: nil, http_status: nil, sql: nil, original_error: nil) ⇒ QueryError

Returns a new instance of QueryError.

Parameters:

  • message (String) (defaults to: nil)

    the error message

  • code (Integer, nil) (defaults to: nil)

    ClickHouse error code

  • http_status (String, nil) (defaults to: nil)

    HTTP response status

  • sql (String, nil) (defaults to: nil)

    the SQL query that failed

  • original_error (Exception, nil) (defaults to: nil)

    the underlying exception



50
51
52
53
54
55
# File 'lib/clickhouse_ruby/errors.rb', line 50

def initialize(message = nil, code: nil, http_status: nil, sql: nil, original_error: nil)
  @code = code
  @http_status = http_status
  @sql = sql
  super(message, original_error: original_error)
end

Instance Attribute Details

#codeInteger? (readonly)

Returns ClickHouse error code.

Returns:

  • (Integer, nil)

    ClickHouse error code



37
38
39
# File 'lib/clickhouse_ruby/errors.rb', line 37

def code
  @code
end

#http_statusString? (readonly)

Returns HTTP status code from the response.

Returns:

  • (String, nil)

    HTTP status code from the response



40
41
42
# File 'lib/clickhouse_ruby/errors.rb', line 40

def http_status
  @http_status
end

#sqlString? (readonly)

Returns the SQL that caused the error.

Returns:

  • (String, nil)

    the SQL that caused the error



43
44
45
# File 'lib/clickhouse_ruby/errors.rb', line 43

def sql
  @sql
end

Instance Method Details

#detailed_messageString

Returns a detailed error message including context

Returns:

  • (String)

    the detailed error message



60
61
62
63
64
65
66
# File 'lib/clickhouse_ruby/errors.rb', line 60

def detailed_message
  parts = [message]
  parts << "Code: #{code}" if code
  parts << "HTTP Status: #{http_status}" if http_status
  parts << "SQL: #{sql}" if sql
  parts.join(' | ')
end