59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
|
package domain
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"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,
|
||
|
SendMailErrorCode.ToUint32(),
|
||
|
fmt.Sprintf("%s", strings.Join(s, " ")))
|
||
|
}
|
||
|
|
||
|
// SendMailErrorL logs error message and returns Err
|
||
|
func SendMailErrorL(l logx.Logger, filed []logx.LogField, s ...string) *errs.LibError {
|
||
|
e := SendMailError(s...)
|
||
|
if filed != nil || len(filed) >= 0 {
|
||
|
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,
|
||
|
SendSMSErrorCode.ToUint32(),
|
||
|
fmt.Sprintf("%s", strings.Join(s, " ")))
|
||
|
}
|
||
|
|
||
|
// SendSMSErrorL logs error message and returns Err
|
||
|
func SendSMSErrorL(l logx.Logger, filed []logx.LogField, s ...string) *errs.LibError {
|
||
|
e := SendSMSError(s...)
|
||
|
if filed != nil || len(filed) >= 0 {
|
||
|
l.WithCallerSkip(1).WithFields(filed...).Error(e.Error())
|
||
|
}
|
||
|
l.WithCallerSkip(1).Error(e.Error())
|
||
|
|
||
|
return e
|
||
|
}
|