This commit is contained in:
2026-10-03 01:09:06 +07:00
parent fc2586f72a
commit 3f7731411b
7 changed files with 169 additions and 64 deletions
+23
View File
@@ -0,0 +1,23 @@
package app
import (
"errors"
"evening_detective_server/internal/services/answer_service"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func answerErrorStatus(err error, internalMessage string) error {
switch {
case errors.Is(err, answer_service.ErrTeamNotFound), errors.Is(err, answer_service.ErrGameNotFound):
return status.Error(codes.NotFound, err.Error())
case errors.Is(err, answer_service.ErrQuestionNotFound), errors.Is(err, answer_service.ErrOfflineAnswers):
return status.Error(codes.InvalidArgument, err.Error())
case errors.Is(err, answer_service.ErrGameFinished), errors.Is(err, answer_service.ErrGameNotStarted), errors.Is(err, answer_service.ErrGameNotFinished):
return status.Error(codes.FailedPrecondition, err.Error())
default:
return status.Error(codes.Internal, internalMessage)
}
}