Exception: Graphlient::Errors::GraphQLError

Inherits:
Error
  • Object
show all
Defined in:
lib/graphlient/errors/graphql_error.rb

Instance Attribute Summary collapse

Attributes inherited from Error

#inner_exception

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ GraphQLError

Returns a new instance of GraphQLError.



5
6
7
8
# File 'lib/graphlient/errors/graphql_error.rb', line 5

def initialize(response)
  super('the server responded with a GraphQL error')
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/graphlient/errors/graphql_error.rb', line 4

def response
  @response
end

Instance Method Details

#errorsObject



10
11
12
# File 'lib/graphlient/errors/graphql_error.rb', line 10

def errors
  @response.errors
end

#to_sObject



14
15
16
17
18
19
# File 'lib/graphlient/errors/graphql_error.rb', line 14

def to_s
  errors.details.map do |key, details|
    details = create_details(details).join("\n")
    [key == 'data' ? nil : key, details].compact.join(': ')
  end.join("\n")
end