Module: Docker::Remote::Utils

Included in:
BearerAuth, Client
Defined in:
lib/docker/remote/utils.rb

Instance Method Summary collapse

Instance Method Details

#potentially_raise_error!(response) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/docker/remote/utils.rb', line 4

def potentially_raise_error!(response)
  case response.code.to_i
    when 401
      raise UnauthorizedError, "401 Unauthorized: #{response.message}"
    when 404
      raise NotFoundError, "404 Not Found: #{response.message}"
  end

  case response.code.to_i / 100
    when 4
      raise ClientError, "#{response.code}: #{response.message}"
    when 5
      raise ServerError, "#{response.code}: #{response.message}"
  end
end