Sha256: 1dfff60a5e14e02bbdfbe11d64788605ad04afd1e4d19e3e20a4b7b6c9dc745e
Contents?: true
Size: 930 Bytes
Versions: 2
Compression:
Stored size: 930 Bytes
Contents
module Faraday # HTTP Status X-Error-Code X-Error # 400 138 Missing consumer key. # 403 152 Invalid consumer key. # 400 181 Invalid redirect uri. # 400 182 Missing code. # 400 185 Code not found. # 403 158 User rejected code. # 403 159 Already used code. # 50X 199 Pocket server issue. # # @see http://getpocket.com/developer/docs/authentication class Response::RaisePocketError < Response::Middleware CLIENT_ERRORS_STATUSES = 400...600 def on_complete(env) case env[:status] when 404 raise Faraday::Error::ResourceNotFound, response_values(env) when 400...403 raise Pocket::Error, env[:response_headers]["X-Error"] when CLIENT_ERRORS_STATUSES raise Faraday::Error::ClientError, response_values(env) end end def response_values(env) {status: env[:status], headers: env[:response_headers], body: env[:body]} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pocket-ruby-andyw8-0.1.0 | lib/faraday/raise_pocket_error.rb |
pocket-ruby-andyw8-0.0.8 | lib/faraday/raise_pocket_error.rb |