Skip to content

Commit

Permalink
🎨 优化美团异常结果
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Manson committed Mar 10, 2021
1 parent 665d8a5 commit a0f4a49
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions meituan/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package meituan

import (
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -125,8 +126,12 @@ func checkResponseBody(body io.ReadCloser) (result []byte, err error) {
if err = meiTuanResponse.Parse(result); err == nil {
// 美团响应data为ng时,为处理失败
if strings.ToLower(meiTuanResponse.Data) == "ng" {
err = fmt.Errorf("checkResponseBody response.data equels ng. error:%+v", meiTuanResponse.Error)
return
if meiTuanResponse.Error != nil {
b, _ := json.Marshal(meiTuanResponse.Error)
err = fmt.Errorf(string(b))
} else {
err = errors.New(meiTuanResponse.Data)
}
}
}
}
Expand Down

0 comments on commit a0f4a49

Please sign in to comment.