Exception: GraphWeaver::ServerError
- 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
-
#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.
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
86 87 88 |
# File 'lib/graph_weaver/errors.rb', line 86 def body @body end |
#status ⇒ Object (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_h ⇒ Object
97 98 99 |
# File 'lib/graph_weaver/errors.rb', line 97 def to_h super.merge("status" => status) end |