fish2018/pansou · error

请求失败

Error message

请求失败

What it means

Defensive fallback in zlxapp doRequestWithRetry: lastErr is still nil after the loop, which can only happen with zero retries configured (maxRetries <= 0). In normal operation the loop always sets lastErr; this generic sentinel prevents returning a nil error with a nil response.

Solutions

  1. Guard maxRetries >= 1 at the call site
  2. Treat as a configuration bug: fix the retry count
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at plugin/zlxapp/zlxapp.go:170 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/2baaba4e7959925a. Report an issue: GitHub.

Appendix: source

Thrown at plugin/zlxapp/zlxapp.go:170

				timer.Stop()
				return nil, req.Context().Err()
			}
		}

		resp, err := client.Do(req.Clone(req.Context()))
		if err != nil {
			lastErr = err
			continue
		}
		if resp.StatusCode == http.StatusOK {
			return resp, nil
		}

		lastErr = fmt.Errorf("HTTP %d", resp.StatusCode)
		resp.Body.Close()
	}
	if lastErr == nil {
		lastErr = fmt.Errorf("请求失败")
	}
	return nil, lastErr
}

func parseListItems(body []byte) ([]searchItem, error) {
	markerIndex := bytes.Index(body, listItemsMarker)
	if markerIndex < 0 {
		return nil, fmt.Errorf("未找到 listItemsData")
	}

	arrayStart := markerIndex + len(listItemsMarker)
	for arrayStart < len(body) && body[arrayStart] != '[' {
		arrayStart++
	}
	if arrayStart >= len(body) {
		return nil, fmt.Errorf("listItemsData 缺少数组")
	}

View on GitHub (pinned to beaa561337)