Exception: GraphWeaver::ServerError

Inherits:
Error
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/graph_weaver/errors.rb

Overview

The request reached the server but it returned a non-2xx status — a 500 that exploded, a 502 from a proxy, a 401, etc. Distinct from a GraphQL error: we got an HTTP response, it just wasn't success.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, body: nil) ⇒ ServerError

Returns a new instance of ServerError.



89
90
91
92
93
94
# File 'lib/graph_weaver/errors.rb', line 89

def initialize(status:, body: nil)
  @status = status
  @body = body
  snippet = body.to_s.empty? ? "" : ": #{body.to_s[0, 500]}"
  super("HTTP #{status}#{snippet}")
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



86
87
88
# File 'lib/graph_weaver/errors.rb', line 86

def body
  @body
end

#statusObject (readonly)

Returns the value of attribute status.



83
84
85
# File 'lib/graph_weaver/errors.rb', line 83

def status
  @status
end

Instance Method Details

#to_hObject



97
98
99
# File 'lib/graph_weaver/errors.rb', line 97

def to_h
  super.merge("status" => status)
end