protected static int handleResponseCode(HttpURLConnection connection)
			throws RestResourceException {
		try {
			int status = connection.getResponseCode();
			String url = connection.getURL().toString();
			String method = connection.getRequestMethod();
			if (status == UNAUTHORIZED_ACCESS)
				throw new UnauthorizedAccessException(status, method, url);
			else if (status == FORBIDDEN_ACCESS)
				throw new ForbiddenAccessException(status, method, url);
			else if (status == RESOURCE_INVALID)
				throw new ResourceInvalidException(status, method, url);
			else if (status == NOT_FOUND)
				throw new ResourceNotFoundException(status, method, url);
			else if (status >= 400 && status < 500)
				throw new ClientException(status, method, url);
			else if (status >= 500 && status < 600)
				throw new ServerException(status, method, url);
			return status;
		} catch (IOException e) {
			throw new RestResourceException("Error while reading the response"
					+ " code", e);
		}
	}