Exception: GraphQL::ParseError

Inherits:
Error
  • Object
show all
Defined in:
lib/graphql/parse_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, line, col, query, filename: nil) ⇒ ParseError


6
7
8
9
10
11
12
13
14
15
# File 'lib/graphql/parse_error.rb', line 6

def initialize(message, line, col, query, filename: nil)
  if filename
    message += " (#{filename})"
  end

  super(message)
  @line = line
  @col = col
  @query = query
end

Instance Attribute Details

#colObject (readonly)

Returns the value of attribute col


5
6
7
# File 'lib/graphql/parse_error.rb', line 5

def col
  @col
end

#lineObject (readonly)

Returns the value of attribute line


5
6
7
# File 'lib/graphql/parse_error.rb', line 5

def line
  @line
end

#queryObject (readonly)

Returns the value of attribute query


5
6
7
# File 'lib/graphql/parse_error.rb', line 5

def query
  @query
end

Instance Method Details

#to_hObject


17
18
19
20
21
22
23
# File 'lib/graphql/parse_error.rb', line 17

def to_h
  locations = line ? [{ "line" => line, "column" => col }] : []
  {
    "message" => message,
    "locations" => locations,
  }
end