Exception: Animoto::HTTPError

Inherits:
Error
  • Object
show all
Defined in:
lib/animoto/support/errors.rb

Overview

Raised when something goes wrong over HTTP

Constant Summary collapse

CODE_STRINGS =
Hash.new("Error").merge({
  400 => "Bad Request",
  401 => "Unauthorized",
  403 => "Forbidden",
  404 => "Not Found",
  405 => "Method Not Allowed",
  406 => "Not Acceptable",
  410 => "Gone",
  411 => "Length Required",
  413 => "Request Entity Too Large",
  415 => "Unsupported Media Type",
  500 => "Internal Server Error",
  501 => "Not Implemented",
  503 => "Service Unavailable"
})

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, code, body) ⇒ HTTPError

Returns a new instance of HTTPError.



30
31
32
33
34
35
36
# File 'lib/animoto/support/errors.rb', line 30

def initialize url, code, body
  @url, @code = url, code
  @details = body['response']['status']['errors'] rescue []
  str = "HTTP #{@code} (#{CODE_STRINGS[@code]}) when requesting #{@url.inspect}"
  str += "\n#{@details.join("\n")}" unless @details.empty?
  super str
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



28
29
30
# File 'lib/animoto/support/errors.rb', line 28

def code
  @code
end

#detailsObject (readonly)

Returns the value of attribute details.



28
29
30
# File 'lib/animoto/support/errors.rb', line 28

def details
  @details
end

#urlObject (readonly)

Returns the value of attribute url.



28
29
30
# File 'lib/animoto/support/errors.rb', line 28

def url
  @url
end