From e1ea9e33ee32a30920d687dcd2c6421496a76795 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Wed, 5 Jul 2023 09:58:45 +0800 Subject: [PATCH] chore: use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) Signed-off-by: guoguangwu --- pkg/common/db/unrelation/extend_msg.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/common/db/unrelation/extend_msg.go b/pkg/common/db/unrelation/extend_msg.go index ab2b8b2b3..8132e5dd4 100644 --- a/pkg/common/db/unrelation/extend_msg.go +++ b/pkg/common/db/unrelation/extend_msg.go @@ -109,7 +109,7 @@ func (e *ExtendMsgSetMongoDriver) InsertOrUpdateReactionExtendMsgSet(ctx context return utils.Wrap(err, "") } if set == nil { - return errors.New(fmt.Sprintf("conversationID %s has no set", conversationID)) + return fmt.Errorf("conversationID %s has no set", conversationID) } _, err = e.ExtendMsgSetCollection.UpdateOne(ctx, bson.M{"source_id": set.ConversationID, "session_type": sessionType}, bson.M{"$set": updateBson}, opt) return utils.Wrap(err, "") @@ -126,7 +126,7 @@ func (e *ExtendMsgSetMongoDriver) DeleteReactionExtendMsgSet(ctx context.Context return utils.Wrap(err, "") } if set == nil { - return errors.New(fmt.Sprintf("conversationID %s has no set", conversationID)) + return fmt.Errorf("conversationID %s has no set", conversationID) } _, err = e.ExtendMsgSetCollection.UpdateOne(ctx, bson.M{"source_id": set.ConversationID, "session_type": sessionType}, bson.M{"$unset": updateBson}) return err @@ -149,5 +149,5 @@ func (e *ExtendMsgSetMongoDriver) TakeExtendMsg(ctx context.Context, conversatio if v, ok := setList[0].ExtendMsgs[clientMsgID]; ok { return &v, nil } - return nil, errors.New(fmt.Sprintf("cant find client msg id: %s", clientMsgID)) + return nil, fmt.Errorf("cant find client msg id: %s", clientMsgID) }