diff --git a/consts/errorcode/error_code.go b/consts/errorcode/error_code.go index 4c7bc59..fc9e00c 100644 --- a/consts/errorcode/error_code.go +++ b/consts/errorcode/error_code.go @@ -3,6 +3,7 @@ package errorcode const ( OK = "OK" OperationFailed = "OperationFailed" + DataNotFound = "DataNotFound" BadArgument = "BadArgument" TaskNotFound = "TaskNotFound" ) diff --git a/pkgs/cmdtrie/command_trie.go b/pkgs/cmdtrie/command_trie.go index db6c821..5f86407 100644 --- a/pkgs/cmdtrie/command_trie.go +++ b/pkgs/cmdtrie/command_trie.go @@ -10,6 +10,8 @@ import ( "gitlink.org.cn/cloudream/common/utils/reflect2" ) +var ErrCommandNotFound = fmt.Errorf("command not found") + type ExecuteOption struct { ReplaceEmptyArrayWithNil bool // 如果最后一个参数是空数组,则调用命令的时候传递nil参数 } @@ -178,7 +180,7 @@ func (t *anyCommandTrie) findCommand(cmdWords []string, argWords []string) (*com }) if cmd == nil { - return nil, nil, fmt.Errorf("command not found") + return nil, nil, ErrCommandNotFound } return cmd, argWords, nil } diff --git a/pkgs/mq/client.go b/pkgs/mq/client.go index db68963..8d6f090 100644 --- a/pkgs/mq/client.go +++ b/pkgs/mq/client.go @@ -22,12 +22,12 @@ const ( var ErrWaitResponseTimeout = fmt.Errorf("wait response timeout") type CodeMessageError struct { - code string - message string + Code string + Message string } func (e *CodeMessageError) Error() string { - return fmt.Sprintf("code: %s, message: %s", e.code, e.message) + return fmt.Sprintf("code: %s, message: %s", e.Code, e.Message) } type SendOption struct { @@ -315,8 +315,8 @@ func Request[TSvc any, TReq MessageBody, TResp MessageBody](_ func(svc TSvc, msg errCode, errMsg := resp.GetCodeMessage() if errCode != errorcode.OK { return defRet, &CodeMessageError{ - code: errCode, - message: errMsg, + Code: errCode, + Message: errMsg, } }