fix(model): avoid shadowing response error
This commit is contained in:
1 parent
5e3fd4cd0f
commit
f53e6e68e2
1 file changed
+3
-3
@@ -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)))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user