Exception: SparkConnect::SparkConnectError

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

Overview

Wraps an error returned by the Spark Connect server (a gRPC failure carrying a Spark error payload). The original gRPC exception is available via #cause, and Spark’s error class / SQL state are surfaced when present.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, error_class: nil, sql_state: nil, grpc_code: nil, stack_trace: []) ⇒ SparkConnectError

Returns a new instance of SparkConnectError.



36
37
38
39
40
41
42
# File 'lib/spark_connect/errors.rb', line 36

def initialize(message, error_class: nil, sql_state: nil, grpc_code: nil, stack_trace: [])
  super(message)
  @error_class = error_class
  @sql_state = sql_state
  @grpc_code = grpc_code
  @stack_trace = stack_trace
end

Instance Attribute Details

#error_classString? (readonly)

Returns Spark’s canonical error class, e.g. ‘“TABLE_OR_VIEW_NOT_FOUND”`, when the server provided one.

Returns:

  • (String, nil)

    Spark’s canonical error class, e.g. ‘“TABLE_OR_VIEW_NOT_FOUND”`, when the server provided one.



25
26
27
# File 'lib/spark_connect/errors.rb', line 25

def error_class
  @error_class
end

#grpc_codeString? (readonly)

Returns the gRPC status code name, e.g. ‘“UNAVAILABLE”`.

Returns:

  • (String, nil)

    the gRPC status code name, e.g. ‘“UNAVAILABLE”`.



31
32
33
# File 'lib/spark_connect/errors.rb', line 31

def grpc_code
  @grpc_code
end

#sql_stateString? (readonly)

Returns the ANSI SQL state, when present.

Returns:

  • (String, nil)

    the ANSI SQL state, when present.



28
29
30
# File 'lib/spark_connect/errors.rb', line 28

def sql_state
  @sql_state
end

#stack_traceArray<String> (readonly)

Returns the server-side stack trace lines, when present.

Returns:

  • (Array<String>)

    the server-side stack trace lines, when present.



34
35
36
# File 'lib/spark_connect/errors.rb', line 34

def stack_trace
  @stack_trace
end