Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

style(tag): Incorrect error handling

LinkinStar6a43e561757a
diff --git a/internal/service/search_parser/search_parser.go b/internal/service/search_parser/search_parser.go
index 3fbbba56..bd8db3f9 100644
--- a/internal/service/search_parser/search_parser.go
+++ b/internal/service/search_parser/search_parser.go
@@ -191,7 +191,7 @@ func (sp *SearchParser) parseUserID(query *string, currentUserID string) (userID
res := re.FindStringSubmatch(q)
if len(res) == 2 {
name := res[1]
- user, has, err := sp.userCommon.GetUserBasicInfoByUserName(nil, name)
+ user, has, err := sp.userCommon.GetUserBasicInfoByUserName(context.TODO(), name)
if err == nil && has {
userID = user.ID
q = re.ReplaceAllString(q, "")
diff --git a/internal/service/siteinfo_common/siteinfo_service_test.go b/internal/service/siteinfo_common/siteinfo_service_test.go
index b3e15a22..4d80c67a 100644
--- a/internal/service/siteinfo_common/siteinfo_service_test.go
+++ b/internal/service/siteinfo_common/siteinfo_service_test.go
@@ -1,6 +1,7 @@
package siteinfo_common
import (
+ "context"
"testing"
"github.com/answerdev/answer/internal/base/constant"
@@ -25,7 +26,7 @@ func TestSiteInfoCommonService_GetSiteGeneral(t *testing.T) {
defer ctl.Finish()
mockInit(ctl)
siteInfoCommonService := NewSiteInfoCommonService(mockSiteInfoRepo)
- resp, err := siteInfoCommonService.GetSiteGeneral(nil)
+ resp, err := siteInfoCommonService.GetSiteGeneral(context.TODO())
assert.NoError(t, err)
assert.Equal(t, resp.Name, "name")
}
diff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.go
index dfdb832a..4f167bd9 100644
--- a/internal/service/tag_common/tag_common.go
+++ b/internal/service/tag_common/tag_common.go
@@ -212,6 +212,9 @@ func (ts *TagCommonService) ExistRecommend(ctx context.Context, tags []*schema.T
// GetObjectTag get object tag
func (ts *TagCommonService) GetObjectTag(ctx context.Context, objectId string) (objTags []*schema.TagResp, err error) {
tagsInfoList, err := ts.GetObjectEntityTag(ctx, objectId)
+ if err != nil {
+ return nil, err
+ }
return ts.TagFormat(ctx, tagsInfoList)
}