app-cloudep-notification-se.../internal/domain/errors.go

56 lines
1.3 KiB
Go
Raw Normal View History

2024-08-27 14:24:56 +00:00
package domain
import (
"strings"
"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)
}
const (
_ = iota
SendMailErrorCode ErrorCode = iota
SendSMSErrorCode
)
// SendMailError ...
func SendMailError(s ...string) *errs.LibError {
return errs.NewError(code.CloudEPNotification, code.ThirdParty,
2024-09-04 19:09:48 +00:00
SendMailErrorCode.ToUint32(), strings.Join(s, " "))
2024-08-27 14:24:56 +00:00
}
// SendMailErrorL logs error message and returns Err
func SendMailErrorL(l logx.Logger, filed []logx.LogField, s ...string) *errs.LibError {
e := SendMailError(s...)
2024-09-04 19:09:48 +00:00
if filed != nil || len(filed) > 0 {
2024-08-27 14:24:56 +00:00
l.WithCallerSkip(1).WithFields(filed...).Error(e.Error())
}
l.WithCallerSkip(1).Error(e.Error())
return e
}
// SendSMSError ...
func SendSMSError(s ...string) *errs.LibError {
return errs.NewError(code.CloudEPNotification, code.ThirdParty,
2024-09-04 19:09:48 +00:00
SendSMSErrorCode.ToUint32(), strings.Join(s, " "))
2024-08-27 14:24:56 +00:00
}
// SendSMSErrorL logs error message and returns Err
func SendSMSErrorL(l logx.Logger, filed []logx.LogField, s ...string) *errs.LibError {
e := SendSMSError(s...)
2024-09-04 19:09:48 +00:00
if filed != nil || len(filed) > 0 {
2024-08-27 14:24:56 +00:00
l.WithCallerSkip(1).WithFields(filed...).Error(e.Error())
}
l.WithCallerSkip(1).Error(e.Error())
return e
}