func checkResponse()

in sharedlibraries/storage/multipart.go [334:351]


func checkResponse(resp *http.Response) error {
	if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusNoContent {
		return nil
	}

	errStr := http.StatusText(resp.StatusCode)
	debugID := resp.Header.Get("x-guploader-uploadid")
	if resp.Body != nil {
		body, readErr := io.ReadAll(resp.Body)
		if readErr != nil {
			return fmt.Errorf("%w (failed to read response body); %s; x-guploader-uploadid=%s", readErr, errStr, debugID)
		}
		if bodyStr := string(body); bodyStr != "" {
			errStr = bodyStr
		}
	}
	return fmt.Errorf("%s; x-guploader-uploadid=%s", errStr, debugID)
}