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.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/graphql/float_encoding_error.rb', line 14

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

#fieldGraphQL::Schema::Field (readonly)

Returns The field that returned a non-finite float.

Returns:



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

def field
  @field
end

#float_valueObject (readonly)

The value which couldn't be encoded



6
7
8
# File 'lib/graphql/float_encoding_error.rb', line 6

def float_value
  @float_value
end

#pathArray<String, Integer> (readonly)

Returns Where the field appeared in the GraphQL response.

Returns:

  • (Array<String, Integer>)

    Where the field appeared in the GraphQL response



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

def path
  @path
end