code: def check_status(status, expected, path, headers=None,
                   resp_headers=None, body=None, extras=None):
    
    if status in expected:
      return
  
    msg = ('Expect status %r from Google Storage. But got status %d.\n'
           'Path: %r.\n'
           'Request headers: %r.\n'
           'Response headers: %r.\n'
           'Body: %r.\n'
           'Extra info: %r.\n' %
           (expected, status, path, headers, resp_headers, body, extras))
  
    if status == httplib.UNAUTHORIZED:
      raise AuthorizationError(msg)
    elif status == httplib.FORBIDDEN:
      raise ForbiddenError(msg)
    elif status == httplib.NOT_FOUND:
      raise NotFoundError(msg)
    elif status == httplib.REQUEST_TIMEOUT:
      raise TimeoutError(msg)
    elif status == httplib.REQUESTED_RANGE_NOT_SATISFIABLE:
      raise InvalidRange(msg)
    elif (status == httplib.OK and 308 in expected and
          httplib.OK not in expected):
      raise FileClosedError(msg)
    elif status >= 500:
      raise ServerError(msg)
    else:
      raise FatalError(msg)
docs: Check HTTP response status is expected.
  
    Args:
      status: HTTP response status. int.
      expected: a list of expected statuses. A list of ints.
      path: filename or a path prefix.
      headers: HTTP request headers.
      resp_headers: HTTP response headers.
      body: HTTP response body.
      extras: extra info to be logged verbatim if error occurs.
  
    Raises:
      AuthorizationError: if authorization failed.
      NotFoundError: if an object that's expected to exist doesn't.
      TimeoutError: if HTTP request timed out.
      ServerError: if server experienced some errors.
      FatalError: if any other unexpected errors occurred.