Exception: Vra::Exception::HTTPError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Vra::Exception::HTTPError
- Defined in:
- lib/vra/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.
31 32 33 34 35 36 37 38 39 |
# File 'lib/vra/exceptions.rb', line 31 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.
30 31 32 |
# File 'lib/vra/exceptions.rb', line 30 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
30 31 32 |
# File 'lib/vra/exceptions.rb', line 30 def code @code end |
#errors ⇒ Object
Returns the value of attribute errors.
30 31 32 |
# File 'lib/vra/exceptions.rb', line 30 def errors @errors end |
#klass ⇒ Object
Returns the value of attribute klass.
30 31 32 |
# File 'lib/vra/exceptions.rb', line 30 def klass @klass end |
#path ⇒ Object
Returns the value of attribute path.
30 31 32 |
# File 'lib/vra/exceptions.rb', line 30 def path @path end |
Instance Method Details
#parse_errors ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vra/exceptions.rb', line 41 def parse_errors begin data = FFI_Yajl::Parser.parse(@body) rescue FFI_Yajl::ParseError return end return if data.nil? return unless data["errors"].respond_to?(:each) data["errors"].each do |error| if error["systemMessage"] @errors << error["systemMessage"] else @errors << error["message"] end end end |