Module: Netflix::Error
- Defined in:
- lib/netflix/errors.rb
Defined Under Namespace
Classes: BadRequest, ClientError, Forbidden, NotFound, RateLimit, ResponseError, ServerError, Unauthorized
Constant Summary collapse
- CODEMAP =
{400 => BadRequest, 403 => Forbidden, 404 => NotFound, 401 => Unauthorized, 420 => RateLimit}
Class Method Summary collapse
Class Method Details
.for(response) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/netflix/errors.rb', line 37 def self.for(response) #codemap = {400 => BadRequest, 403 => Forbidden, 404 => NotFound, 401 => Unauthorized, 420 => RateLimit} code = response.code.to_i (CODEMAP[code] || ResponseError).new(response.body, response.header) #codemap[code].new(response.body, response.header) end |