class Akamai::Core::Client::Error

Attributes

body[R]

Public Class Methods

new(body) click to toggle source
# File lib/akamai/core/client/error.rb, line 10
def initialize(body)
  @body = /Array/ =~ body.class.name ? body[0] : body
end

Public Instance Methods

exist?() click to toggle source
# File lib/akamai/core/client/error.rb, line 14
def exist?
  !!message
end
raise_error() click to toggle source
# File lib/akamai/core/client/error.rb, line 18
def raise_error
  error = AkamaiError.new.tap do |akamai_error|
    akamai_error.body = body
  end
  raise(error, message) if exist?
end

Private Instance Methods

message() click to toggle source
# File lib/akamai/core/client/error.rb, line 27
def message
  @message ||=
    case body.class.name
    when /Hash/
      if body[:errorString]
        body[:errorString]
      elsif body[:status] && /^4\d{2}|^5\d{2}/ =~ body[:status].to_s
        body[:detail]
      end
    end
end