Exception: GraphWeaver::ServerError
- 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
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(status:, body: nil) ⇒ ServerError
constructor
A new instance of ServerError.
- #to_h ⇒ Object
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
66 67 68 |
# File 'lib/graph_weaver/errors.rb', line 66 def body @body end |
#status ⇒ Object (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_h ⇒ Object
75 76 77 |
# File 'lib/graph_weaver/errors.rb', line 75 def to_h super.merge("status" => status) end |