fix(tts): handle io.ReadAll error in error response path
This commit is contained in:
parent
cf67dd3851
commit
e567f1faa1
1 changed files with 4 additions and 1 deletions
|
|
@ -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),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue