Class: Newsfeed::FeedResponseHandler

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/newsfeed/feed.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/newsfeed/feed.rb', line 79

def on_complete(env)
  case env[:status]
  when 200
    nil # this is the expected code
  when 204
    nil # this is another expected code, for empty responses
  when 401
    raise InvalidApiKey
  when 402
    raise ProjectNotFound
  when 404
    raise EntryNotFound
  when 400
    raise DuplicateEntry
  else
    raise UnexpectedHTTPException, env[:body]
  end
end