Exception: Splunk::SplunkHTTPError
- Inherits:
-
StandardError
- Object
- StandardError
- Splunk::SplunkHTTPError
- Defined in:
- lib/splunk-sdk-ruby/splunk_http_error.rb
Overview
Exception to represent all errors returned from Splunkd.
The important information about the error is available as a set of accessors:
-
code
: The HTTP error code returned. -
reason
: The reason field of the HTTP response header. -
detail
: The detailed error message Splunk sent in the response body.
You can also get the original response body from body
and any HTTP headers returns from headers
.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
Instance Method Summary collapse
-
#initialize(response) ⇒ SplunkHTTPError
constructor
A new instance of SplunkHTTPError.
Constructor Details
#initialize(response) ⇒ SplunkHTTPError
Returns a new instance of SplunkHTTPError.
39 40 41 42 43 44 45 46 47 |
# File 'lib/splunk-sdk-ruby/splunk_http_error.rb', line 39 def initialize(response) @body = response.body @detail = Splunk::text_at_xpath("//msg", response.body) @reason = response. @code = Integer(response.code) @headers = response.each().to_a() super("HTTP #{@code.to_s} #{@reason}: #{@detail || ""}") end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
37 38 39 |
# File 'lib/splunk-sdk-ruby/splunk_http_error.rb', line 37 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
37 38 39 |
# File 'lib/splunk-sdk-ruby/splunk_http_error.rb', line 37 def code @code end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
37 38 39 |
# File 'lib/splunk-sdk-ruby/splunk_http_error.rb', line 37 def detail @detail end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
37 38 39 |
# File 'lib/splunk-sdk-ruby/splunk_http_error.rb', line 37 def headers @headers end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
37 38 39 |
# File 'lib/splunk-sdk-ruby/splunk_http_error.rb', line 37 def reason @reason end |