Exception: Vra::Exception::HTTPError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Vra::Exception::HTTPError
- Defined in:
- lib/vra-restapi/exceptions.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ HTTPError
constructor
A new instance of HTTPError.
- #parse_errors ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ HTTPError
Returns a new instance of HTTPError.
30 31 32 33 34 35 36 37 38 |
# File 'lib/vra-restapi/exceptions.rb', line 30 def initialize(opts={}) @code = opts[:code] @body = opts[:body] @path = opts[:path] @klass = opts[:klass] @errors = [] parse_errors end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
29 30 31 |
# File 'lib/vra-restapi/exceptions.rb', line 29 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
29 30 31 |
# File 'lib/vra-restapi/exceptions.rb', line 29 def code @code end |
#errors ⇒ Object
Returns the value of attribute errors.
29 30 31 |
# File 'lib/vra-restapi/exceptions.rb', line 29 def errors @errors end |
#klass ⇒ Object
Returns the value of attribute klass.
29 30 31 |
# File 'lib/vra-restapi/exceptions.rb', line 29 def klass @klass end |
#path ⇒ Object
Returns the value of attribute path.
29 30 31 |
# File 'lib/vra-restapi/exceptions.rb', line 29 def path @path end |
Instance Method Details
#parse_errors ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vra-restapi/exceptions.rb', line 40 def parse_errors begin if @body.nil? return end data = JSON.parse(@body) rescue JSON::ParserError => e return end return if data.nil? return unless data['errors'].respond_to?(:each) data['errors'].each do |error| @errors << error['systemMessage'] end end |