Skip to content

Commit

Permalink
增加详细斗鱼错误信息 (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
kira1928 authored Aug 5, 2023
1 parent 346816a commit 6de7c3d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/live/douyu/douyu.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (l *Live) fetchRoomID() error {
func (l *Live) GetInfo() (info *live.Info, err error) {
if err := l.fetchRoomID(); err != nil {
if err.Error() == "房间未开放" {
return nil, live.ErrRoomNotExist
return nil, errors.New("room not exists, fetchRoomID failed.")
} else if err.Error() == "房间被关闭" {
return &live.Info{
Live: l,
Expand All @@ -208,7 +208,7 @@ func (l *Live) GetInfo() (info *live.Info, err error) {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, live.ErrRoomNotExist
return nil, errors.New(fmt.Sprintf("GetInfo() failed, response code: %d", resp.StatusCode))
}
body, err := resp.Bytes()
if err != nil {
Expand All @@ -230,7 +230,7 @@ func (l *Live) getSignParams() (map[string]string, error) {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, live.ErrRoomNotExist
return nil, errors.New(fmt.Sprintf("getSignParams() failed, response code: %d", resp.StatusCode))
}
body, err := resp.Bytes()
if err != nil {
Expand Down Expand Up @@ -332,8 +332,8 @@ func (l *Live) GetStreamUrls() (us []*url.URL, err error) {
if err != nil {
return nil, err
}
if gjson.GetBytes(body, "error").Int() != 0 {
return nil, live.ErrRoomNotExist
if errorInt := gjson.GetBytes(body, "error").Int(); errorInt != 0 {
return nil, errors.New(fmt.Sprintf("GetStreamUrls() failed, error: %d", errorInt))
}
return utils.GenUrls(
fmt.Sprintf("%s/%s",
Expand Down

0 comments on commit 6de7c3d

Please sign in to comment.