Class: GraphQL::FloatEncodingError

Inherits:
RuntimeTypeError
  • Object
show all
Defined in:
lib/graphql/float_encoding_error.rb

Overview

This error is raised when Types::Float is asked to return a non-finite value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, context:) ⇒ FloatEncodingError

Returns a new instance of FloatEncodingError.



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/graphql/float_encoding_error.rb', line 20

def initialize(value, context:)
  @float_value = value
  @field = context[:current_field]
  @path = context[:current_path]
  message = "Float is not finite: #{value.inspect}".dup
  if @path
    message << " @ #{@path.join(".")}"
  end
  if @field
    message << " (#{@field.path})"
  end
  super("#{message}.")
end

Instance Attribute Details

#field ⇒ Object (readonly)

Returns

  • GraphQL::Schema::Field — The field that returned a non-finite float


13
14
15
# File 'lib/graphql/float_encoding_error.rb', line 13

def field
  @field
end

#float_value ⇒ Object (readonly)

The value which couldn't be encoded



8
9
10
# File 'lib/graphql/float_encoding_error.rb', line 8

def float_value
  @float_value
end

#path ⇒ Object (readonly)

Returns

  • Array<String, Integer> — Where the field appeared in the GraphQL response


18
19
20
# File 'lib/graphql/float_encoding_error.rb', line 18

def path
  @path
end