Exception: GraphWeaver::ServerError

Inherits:
Error
  • Object
show all
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.



68
69
70
71
72
73
# File 'lib/graph_weaver/errors.rb', line 68

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.



66
67
68
# File 'lib/graph_weaver/errors.rb', line 66

def body
  @body
end

#statusObject (readonly)

Returns the value of attribute status.



66
67
68
# File 'lib/graph_weaver/errors.rb', line 66

def status
  @status
end

Instance Method Details

#to_hObject



75
76
77
# File 'lib/graph_weaver/errors.rb', line 75

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