Class: Response::Tubeclip

Inherits:
Middleware
  • Object
show all
Defined in:
lib/tubeclip/middleware/faraday_tubeclip.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object

this method is called after finish request



3
4
5
6
7
8
9
10
11
12
# File 'lib/tubeclip/middleware/faraday_tubeclip.rb', line 3

def on_complete(env) #this method is called after finish request
  msg = parse_error_from(env[:body])
  if env[:status] == 404
    raise ::Tubeclip::ResourceNotFoundError.new(msg)
  elsif env[:status] == 403 || env[:status] == 401
    raise ::Tubeclip::AuthenticationError.new(msg, env[:status])
  elsif (env[:status] / 10).to_i != 20
    raise ::Tubeclip::UploadError.new(msg, env[:status])
  end
end