fix(tts): handle io.ReadAll error in error response path

This commit is contained in:
程智超0668000959 2026-06-14 23:46:13 +08:00
parent cf67dd3851
commit e567f1faa1

View file

@ -196,7 +196,10 @@ func (t *OpenAITTSProvider) doSpeechRequest(
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
defer resp.Body.Close() defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body) body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
body = []byte(fmt.Sprintf("(failed to read error body: %v)", readErr))
}
return nil, &openAITTSAPIError{ return nil, &openAITTSAPIError{
statusCode: resp.StatusCode, statusCode: resp.StatusCode,
body: string(body), body: string(body),