mirror of
https://github.com/PretendoNetwork/friends.git
synced 2025-04-02 11:01:46 -04:00
Now database getters do error handling aswell, and in case of any error, the NEX or GRPC method throws a proper error about it. There are still some doubts on how to handle errors when a list of data is processed, so for now skip that element on the list and continue. Also add some constant errors to do better error handling.
33 lines
946 B
Go
33 lines
946 B
Go
package grpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
|
|
"github.com/PretendoNetwork/friends/database"
|
|
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
|
"github.com/PretendoNetwork/friends/globals"
|
|
pb "github.com/PretendoNetwork/grpc-go/friends"
|
|
)
|
|
|
|
func (s *gRPCFriendsServer) DenyFriendRequest(ctx context.Context, in *pb.DenyFriendRequestRequest) (*pb.DenyFriendRequestResponse, error) {
|
|
err := database_wiiu.SetFriendRequestDenied(in.GetFriendRequestId())
|
|
if err != nil {
|
|
if err == database.ErrFriendRequestNotFound {
|
|
return &pb.DenyFriendRequestResponse{
|
|
Success: false,
|
|
}, status.Errorf(codes.NotFound, "friend request not found")
|
|
}
|
|
|
|
globals.Logger.Critical(err.Error())
|
|
return &pb.DenyFriendRequestResponse{
|
|
Success: false,
|
|
}, status.Errorf(codes.Internal, "internal server error")
|
|
}
|
|
|
|
return &pb.DenyFriendRequestResponse{
|
|
Success: true,
|
|
}, nil
|
|
}
|