diff --git a/controller/listening/listening.go b/controller/listening/listening.go index f067111..fa2d448 100644 --- a/controller/listening/listening.go +++ b/controller/listening/listening.go @@ -30,14 +30,12 @@ func GetListenRoom(c *gin.Context) { if err != nil { if err == blive.ErrNotFound { - log.Infof("用戶索取 %v 房間資訊時不存在 (%v)", id, c.ClientIP()) c.IndentedJSON(404, gin.H{ "error": "房間不存在", }) return } - log.Warnf("嘗試獲取房間 %v 的直播資訊時出現錯誤: %v (%v)", id, err, c.ClientIP()) c.IndentedJSON(400, gin.H{ "error": err.Error(), }) diff --git a/services/api/room.go b/services/api/room.go index 783b7e7..dc2ab1b 100644 --- a/services/api/room.go +++ b/services/api/room.go @@ -3,7 +3,6 @@ package api import ( "encoding/json" "fmt" - "github.com/eric2788/biligo-live-ws/services/blive" "github.com/eric2788/biligo-live-ws/services/database" "github.com/sirupsen/logrus" "io" @@ -28,7 +27,7 @@ func GetRoomInfoCache(room int64) (*RoomInfo, error) { return roomInfo, nil } else { if _, ok := err.(*database.EmptyError); ok { - return nil, blive.ErrCacheNotFound + return nil, ErrCacheNotFound } else { return nil, err } diff --git a/services/api/user.go b/services/api/user.go index d3eb109..de7f1fc 100644 --- a/services/api/user.go +++ b/services/api/user.go @@ -2,8 +2,8 @@ package api import ( "encoding/json" + "errors" "fmt" - "github.com/eric2788/biligo-live-ws/services/blive" "github.com/eric2788/biligo-live-ws/services/database" "io" "net/http" @@ -12,6 +12,10 @@ import ( const UserInfoApi = "https://api.bilibili.com/x/space/acc/info?mid=%v&jsonp=jsonp" +var ( + ErrCacheNotFound = errors.New("緩存不存在") +) + func GetUserInfoCache(uid int64) (*UserInfo, error) { dbKey := fmt.Sprintf("user:%v", uid) @@ -21,7 +25,7 @@ func GetUserInfoCache(uid int64) (*UserInfo, error) { return userInfo, nil } else { if _, ok := err.(*database.EmptyError); ok { - return nil, blive.ErrCacheNotFound + return nil, ErrCacheNotFound } else { return nil, err } diff --git a/services/blive/live_server.go b/services/blive/live_server.go index 53e0b93..a53d4e8 100644 --- a/services/blive/live_server.go +++ b/services/blive/live_server.go @@ -21,9 +21,8 @@ var ( ) var ( - ErrNotFound = errors.New("房間不存在") - ErrTooFast = errors.New("請求頻繁") - ErrCacheNotFound = errors.New("緩存不存在") + ErrNotFound = errors.New("房間不存在") + ErrTooFast = errors.New("請求頻繁") ) func GetListening() []interface{} {