chore: print error detail when call http api failed with mj

This commit is contained in:
RockYang
2024-01-21 22:30:24 +08:00
parent 412f8ecc6c
commit 66c7717f04
2 changed files with 7 additions and 2 deletions

View File

@@ -5,6 +5,8 @@ import (
logger2 "chatplus/logger"
"errors"
"fmt"
"io"
"github.com/imroc/req/v3"
)
@@ -63,7 +65,8 @@ func (c *Client) Imagine(prompt string) (ImageRes, error) {
SetErrorResult(&errRes).
Post(apiURL)
if err != nil {
return ImageRes{}, fmt.Errorf("请求 API 出错:%v", err)
errStr, _ := io.ReadAll(r.Body)
return ImageRes{}, fmt.Errorf("请求 API 出错:%v%v", err, string(errStr))
}
if r.IsErrorState() {