mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-05 08:13:43 +08:00
fix: resp body when error
This commit is contained in:
@@ -55,10 +55,14 @@ func testChannel(channel *model.Channel, request ChatRequest) error {
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
// Prinnt the body in string
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(resp.Body)
|
||||
return errors.New("error response: " + strconv.Itoa(resp.StatusCode) + " " + buf.String())
|
||||
// Print the body in string
|
||||
if resp.Body != nil {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(resp.Body)
|
||||
return errors.New("error response: " + strconv.Itoa(resp.StatusCode) + " " + buf.String())
|
||||
}
|
||||
|
||||
return errors.New("error response: " + strconv.Itoa(resp.StatusCode))
|
||||
}
|
||||
|
||||
var done = false
|
||||
|
||||
Reference in New Issue
Block a user