add service
All checks were successful
Deploy Smart Search Backend Test / deploy (push) Successful in 1m24s

This commit is contained in:
vallyenfail
2026-01-18 01:48:46 +03:00
parent b6f7323c58
commit 80e5f318a9
23 changed files with 2300 additions and 26 deletions

View File

@@ -6,6 +6,8 @@ const (
AuthInvalidToken = "AUTH_INVALID_TOKEN"
RefreshInvalid = "REFRESH_INVALID"
InviteLimitReached = "INVITE_LIMIT_REACHED"
InviteInvalidOrExpired = "INVITE_INVALID_OR_EXPIRED"
EmailAlreadyExists = "EMAIL_ALREADY_EXISTS"
InsufficientBalance = "INSUFFICIENT_BALANCE"
UserNotFound = "USER_NOT_FOUND"
RequestNotFound = "REQUEST_NOT_FOUND"

View File

@@ -51,6 +51,14 @@ func NewInternalError(code, message string, err error) *AppError {
}
}
func IsBusinessError(err error, code string) bool {
var appErr *AppError
if !errors.As(err, &appErr) {
return false
}
return appErr.Type == BusinessError && appErr.Code == code
}
func ToGRPCError(err error, zapLogger *zap.Logger, method string) error {
if err == nil {
return nil
@@ -85,8 +93,10 @@ func ToGRPCError(err error, zapLogger *zap.Logger, method string) error {
return status.Error(codes.Unauthenticated, appErr.Message)
case InviteLimitReached:
return status.Error(codes.ResourceExhausted, appErr.Message)
case InsufficientBalance:
case InsufficientBalance, InviteInvalidOrExpired:
return status.Error(codes.FailedPrecondition, appErr.Message)
case EmailAlreadyExists:
return status.Error(codes.AlreadyExists, appErr.Message)
case UserNotFound, RequestNotFound:
return status.Error(codes.NotFound, appErr.Message)
default: