Exception: DogTrainer::DogApiException
- Inherits:
-
StandardError
- Object
- StandardError
- DogTrainer::DogApiException
- Defined in:
- lib/dogtrainer/dogapiexception.rb
Overview
Exception raised for Datadog API errors (non-200 status code)
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#statuscode ⇒ Object
readonly
Returns the value of attribute statuscode.
Instance Method Summary collapse
-
#initialize(response) ⇒ DogApiException
constructor
A new instance of DogApiException.
Constructor Details
#initialize(response) ⇒ DogApiException
Returns a new instance of DogApiException.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dogtrainer/dogapiexception.rb', line 7 def initialize(response) @statuscode = response[0] @content = if response.length > 1 response[1] else {} end msg = "Datadog API call returned status #{@statuscode}" if @content.include?('errors') msg << ":\n" if @content['errors'].is_a?(Array) @content['errors'].each { |e| msg << "#{e}\n" } else msg << "#{content['errors']}\n" end end super(msg) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/dogtrainer/dogapiexception.rb', line 5 def content @content end |
#statuscode ⇒ Object (readonly)
Returns the value of attribute statuscode.
4 5 6 |
# File 'lib/dogtrainer/dogapiexception.rb', line 4 def statuscode @statuscode end |