File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,17 @@ func (c *Client) handleErrorResp(resp *http.Response) error {
334334 return singleErrRes .Error
335335 }
336336
337+ // 尝试将响应体反序列化为 ErrorResponse 数组
338+ var errResArray []ErrorResponse
339+ err = json .Unmarshal (body , & errResArray )
340+ if err == nil && len (errResArray ) > 0 {
341+ // 如果反序列化成功且数组不为空
342+ firstErrRes := errResArray [0 ]
343+ firstErrRes .Error .HTTPStatus = resp .Status
344+ firstErrRes .Error .HTTPStatusCode = resp .StatusCode
345+ return firstErrRes .Error
346+ }
347+
337348 //errRes.Error.HTTPStatus = resp.Status
338349 //errRes.Error.HTTPStatusCode = resp.StatusCode
339350 //return errRes.Error
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ type ImageRequest struct {
8383 Moderation string `json:"moderation,omitempty"`
8484 OutputCompression int `json:"output_compression,omitempty"`
8585 OutputFormat string `json:"output_format,omitempty"`
86+ Watermark * bool `json:"watermark,omitempty"`
8687}
8788
8889// ImageResponse represents a response structure for image API.
You can’t perform that action at this time.
0 commit comments