Files
evening_detective_server/internal/app/game_errors.go
T
2026-10-03 01:09:06 +07:00

23 lines
642 B
Go

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)
}
}