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
+22
View File
@@ -0,0 +1,22 @@
package app
import (
"errors"
"evening_detective_server/internal/services/game_service"
"evening_detective_server/internal/services/scenarios_service"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func gameErrorStatus(err error, internalMessage string) error {
switch {
case errors.Is(err, game_service.ErrGameNotFound), errors.Is(err, scenarios_service.ErrScenarioNotFound):
return status.Error(codes.NotFound, err.Error())
case errors.Is(err, game_service.ErrInvalidGameFormat):
return status.Error(codes.InvalidArgument, err.Error())
default:
return status.Error(codes.Internal, internalMessage)
}
}