module AWS::Errors::ModeledError

@private

Attributes

code[R]

@return [Integer] The HTTP status code returned by the AWS service.

message[RW]

@return [String] The error message given by the AWS service.

Public Class Methods

new(req = nil, resp = nil) click to toggle source
# File lib/aws/errors.rb, line 98
def initialize(req = nil, resp = nil)
  if req.kind_of?(String)
    # makes it easier to test handling of modeled exceptions
    super(nil, nil, req)
    @message = req
  elsif req and resp
    super(req, resp, message)
    include_error_type
    parse_body(resp.body)
  else
    super()
  end
end

Public Instance Methods

error_grammar() click to toggle source
# File lib/aws/errors.rb, line 128
def error_grammar
  self.class::BASE_ERROR_GRAMMAR
end
extract_message(body) click to toggle source
# File lib/aws/errors.rb, line 124
def extract_message(body)
  error_grammar.parse(body).message
end
include_error_type() click to toggle source
# File lib/aws/errors.rb, line 112
def include_error_type
  if http_response.status >= 500
    extend ServerError
  else
    extend ClientError
  end
end
parse_body(body) click to toggle source
# File lib/aws/errors.rb, line 120
def parse_body(body)
  error_grammar.parse(body, :context => self)
end