template-monorepo/internal/model/notification/usecase/repo_errors.go

21 lines
561 B
Go
Raw Normal View History

package usecase
import (
"errors"
"gateway/internal/model/notification"
)
func wrapRepoErr(err error) error {
if errors.Is(err, notification.ErrNotFound) {
return errb.ResNotFound("notification", "").WithCause(err)
}
if errors.Is(err, notification.ErrInvalidObjectID) {
return errb.ResInvalidMeasureID("notification id").WithCause(err)
}
if errors.Is(err, notification.ErrDuplicateIdempotency) {
return errb.ResAlreadyExist("notification idempotency key").WithCause(err)
}
return errb.DBError("notification repository error").WithCause(err)
}