2024-08-30 07:08:43 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
ers "code.30cm.net/digimon/library-go/errs"
|
|
|
|
"code.30cm.net/digimon/library-go/errs/code"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ErrorCode uint32
|
|
|
|
|
|
|
|
func (e ErrorCode) ToUint32() uint32 {
|
|
|
|
return uint32(e)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error Code 統一這邊改
|
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
PostMongoErrorCode ErrorCode = iota
|
|
|
|
CreatePostError
|
|
|
|
DelPostError
|
|
|
|
UpdatePostError
|
|
|
|
ListPostError
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
CommentFoundErrorCode ErrorCode = iota + 10
|
|
|
|
CommentInsertErrorCode
|
|
|
|
CommentDeleteErrorCode
|
|
|
|
CommentUpdateErrorCode
|
|
|
|
CommentListErrorCode
|
|
|
|
)
|
|
|
|
|
2024-09-01 13:49:28 +00:00
|
|
|
const (
|
2024-09-01 14:47:24 +00:00
|
|
|
AddTimeLineErrorCode ErrorCode = iota + 20
|
|
|
|
FetchTimeLineErrorCode
|
|
|
|
ClearNoMoreDataErrorCode
|
|
|
|
HasNoMoreDataErrorCode
|
|
|
|
SetNoMoreDataErrorCode
|
2024-09-01 13:49:28 +00:00
|
|
|
)
|
|
|
|
|
2024-09-03 09:11:12 +00:00
|
|
|
const (
|
|
|
|
MarkRelationErrorCode ErrorCode = iota + 30
|
|
|
|
GetFollowerErrorCode
|
|
|
|
GetFollowerCountErrorCode
|
|
|
|
GetFolloweeErrorCode
|
|
|
|
GetFolloweeCountErrorCode
|
|
|
|
RemoveRelationErrorCode
|
|
|
|
)
|
|
|
|
|
2024-08-30 07:08:43 +00:00
|
|
|
func CommentError(ec ErrorCode, s ...string) *ers.LibError {
|
2024-09-03 09:47:34 +00:00
|
|
|
return ers.NewError(code.CloudEPTweeting, code.DBError, ec.ToUint32(), strings.Join(s, " "))
|
2024-08-30 07:08:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func CommentErrorL(ec ErrorCode,
|
|
|
|
l logx.Logger, filed []logx.LogField, s ...string) *ers.LibError {
|
|
|
|
e := CommentError(ec, s...)
|
|
|
|
l.WithCallerSkip(1).WithFields(filed...).Error(e.Error())
|
|
|
|
|
|
|
|
return e
|
|
|
|
}
|