fish2018/pansou · error

创建备用域名请求失败

Error message

创建备用域名请求失败: %w

What it means

Fallback-path error in PanwikiPlugin.searchPage (plugin/panwiki/panwiki.go:187): after the primary domain request failed, the client was switched to the backup domain, but constructing the retry request for the backup domain failed. The domain switch happened; the rebuild itself is what broke.

Solutions

  1. 校验 BackupBaseURL 常量格式
  2. 对备用 URL 做预检验证
  3. 域名切换失败时回退返回原始错误
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at plugin/panwiki/panwiki.go:187 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/16f38529d4805600. Report an issue: GitHub.

Appendix: source

Thrown at plugin/panwiki/panwiki.go:187

	// 不自动跟随重定向
	client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
		return http.ErrUseLastResponse
	}
	
	resp, err := client.Do(req)
	if err != nil {
		// 如果主域名失败,尝试切换到备用域名
		if p.currentBaseURL == PrimaryBaseURL {
			if p.debugMode {
				log.Printf("[Panwiki] 主域名请求失败,尝试备用域名: %v", err)
			}
			p.switchToBackupDomain()
			
			// 重新构建URL并重试
			initialURL = p.getSearchURL(keyword, page)
			req, err = http.NewRequest("GET", initialURL, nil)
			if err != nil {
				return nil, fmt.Errorf("创建备用域名请求失败: %w", err)
			}
			p.setRequestHeaders(req)
			
			resp, err = client.Do(req)
			if err != nil {
				return nil, fmt.Errorf("备用域名请求也失败: %w", err)
			}
		} else {
			return nil, fmt.Errorf("初始请求失败: %w", err)
		}
	}
	defer resp.Body.Close()
	
	// 重置重定向策略
	client.CheckRedirect = nil
	
	// 获取重定向URL
	location := resp.Header.Get("Location")

View on GitHub (pinned to beaa561337)