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

Returns a new instance of ParseError.



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

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.



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

def col
  @col
end

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

#queryObject (readonly)

Returns the value of attribute query.



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

def query
  @query
end

Instance Method Details

#to_hObject



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

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