Class: GraphQL::Execution::Interpreter::ExecutionErrors

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/execution/interpreter/execution_errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(ctx, ast_node, path) ⇒ ExecutionErrors

: (GraphQL::Query::Context ctx, GraphQL::Language::Nodes::AbstractNode ast_node, Array[String | Integer] path) -> void



10
11
12
13
14
# File 'lib/graphql/execution/interpreter/execution_errors.rb', line 10

def initialize(ctx, ast_node, path)
  @context = ctx #: GraphQL::Query::Context
  @ast_node = ast_node #: GraphQL::Language::Nodes::AbstractNode
  @path = path #: Array[String | Integer]
end

Instance Method Details

#add(err_or_msg) ⇒ Object

: (Object err_or_msg) -> void



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/graphql/execution/interpreter/execution_errors.rb', line 17

def add(err_or_msg)
  err = case err_or_msg
  when String
    GraphQL::ExecutionError.new(err_or_msg)
  when GraphQL::ExecutionError
    err_or_msg
  else
    raise ArgumentError, "expected String or GraphQL::ExecutionError, not #{err_or_msg.class} (#{err_or_msg.inspect})"
  end
  err.ast_node ||= @ast_node
  err.path ||= @path
  @context.add_error(err)
end