class Served::Resource::HttpError

Attributes

code[R]
errors[R]
message[R]
response[R]
server_backtrace[R]

Public Class Methods

new(code, resource, response) click to toggle source
Calls superclass method
# File lib/served/resource/http_errors.rb, line 10
def initialize(code, resource, response)
  @code = code

  if resource.serializer.respond_to? :exception
    serialized = resource.serializer.exception(response.body).symbolize_keys!

    @error            = serialized[:error]
    @message          = serialized[:exception]
    @server_backtrace = serialized[:backtrace]
    @response         = OpenStruct.new(serialized) # TODO: remove in served 1.0, used for backwards compat

    super("An error '#{code} #{message}' occurred while making this request")
  else
    super "An error occurred '#{code}'"
  end
end

Public Instance Methods

status() click to toggle source
# File lib/served/resource/http_errors.rb, line 27
def status
  self.class.status
end