class Vra::Exception::HTTPError

Attributes

body[RW]
code[RW]
errors[RW]
klass[RW]
path[RW]

Public Class Methods

new(opts = {}) click to toggle source
# 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

Public Instance Methods

parse_errors() click to toggle source
# 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