Skip to content

Commit

Permalink
change
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonsdpy committed Apr 25, 2023
1 parent 2718bdc commit 3aa0023
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions atrust/internal/common/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 80,7 @@ func (r *Request) Do() (RespData, error) {
client.Timeout = 20 * time.Second
client.Transport = tsp
// 发起请求
fmt.Println(IndentJsonBytes(r.Body))
resp, err := client.Do(req)
if err != nil {
return nil, err
Expand Down
5 changes: 4 additions & 1 deletion atrust/internal/common/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 13,15 @@ type Response struct {
}

func (r Response) ErrorCheck() error {
if r.Code == 0 && r.Msg != "" {
if r.Code == 0 {
return nil
}
if r.Msg != "" {
return errors.New(fmt.Sprintf("code=%d,msg=%s", r.Code, r.Msg))
}
if len(r.Data) > 0 {
return errors.New(string(r.Data))
}
return errors.New("response check failed")
}

Expand Down

0 comments on commit 3aa0023

Please sign in to comment.