fix(model): avoid shadowing response error

This commit is contained in:
Alix-007
2026-06-24 23:35:06 +08:00
parent 5e3fd4cd0f
commit f53e6e68e2
+3 -3
View File
@@ -45,9 +45,9 @@ func fetchOpenAIModels(baseURL, apiKey string) ([]modelEntry, error) {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, err := io.ReadAll(io.LimitReader(resp.Body, 512))
if err != nil {
return nil, fmt.Errorf("read error response: %w", err)
body, readErr := io.ReadAll(io.LimitReader(resp.Body, 512))
if readErr != nil {
return nil, fmt.Errorf("read error response: %w", readErr)
}
return nil, fmt.Errorf("HTTP %d: %s", resp.StatusCode, strings.TrimSpace(string(body)))
}