lib/graphql/string_encoding_error.rb in graphql-1.12.18 vs lib/graphql/string_encoding_error.rb in graphql-1.12.19
- old
+ new
@@ -1,10 +1,20 @@
# frozen_string_literal: true
module GraphQL
class StringEncodingError < GraphQL::RuntimeTypeError
- attr_reader :string
- def initialize(str)
+ attr_reader :string, :field, :path
+ def initialize(str, context:)
@string = str
- super("String \"#{str}\" was encoded as #{str.encoding}! GraphQL requires an encoding compatible with UTF-8.")
+ @field = context[:current_field]
+ @path = context[:current_path]
+ message = "String #{str.inspect} was encoded as #{str.encoding}".dup
+ if @path
+ message << " @ #{@path.join(".")}"
+ end
+ if @field
+ message << " (#{@field.path})"
+ end
+ message << ". GraphQL requires an encoding compatible with UTF-8."
+ super(message)
end
end
end