micro-bundle/pkg/err/common.go
2025-02-20 20:40:39 +08:00

41 lines
968 B
Go

package err
import (
"errors"
"fmt"
"dubbo.apache.org/dubbo-go/v3/common/logger"
"github.com/getsentry/sentry-go"
"go.uber.org/zap"
"micro-bundle/pkg/app"
)
func ReturnError(err error, msg, print string) error {
if err != nil {
sentry.WithScope(func(scope *sentry.Scope) {
scope.SetLevel(sentry.LevelError)
sentry.CaptureMessage(fmt.Sprintf("print:%+v msg:%+v err : %+v", print, msg, err))
})
logger.Error(print, err)
fmt.Printf(print+"%+v\n", err)
return errors.New(msg)
} else {
sentry.CaptureMessage(fmt.Sprintf("print:%+v msg:%+v ", print, msg))
return errors.New(msg)
}
}
func RecordCommonInfo(method, point string, value any) {
sentry.WithScope(func(scope *sentry.Scope) {
scope.SetLevel(sentry.LevelInfo)
scope.SetTag("method : ", method)
if value != nil {
sentry.CaptureMessage(fmt.Sprintf("point:%+v value:%+v ", point, value))
} else {
sentry.CaptureMessage(fmt.Sprintf("point:%+v ", point))
}
})
}