mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-04-25 23:37:46 -05: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.
22 lines
524 B
Go
22 lines
524 B
Go
package globals
|
|
|
|
import (
|
|
"context"
|
|
|
|
pb "github.com/PretendoNetwork/grpc-go/account"
|
|
"github.com/PretendoNetwork/nex-go"
|
|
"google.golang.org/grpc/metadata"
|
|
)
|
|
|
|
func PasswordFromPID(pid uint32) (string, uint32) {
|
|
ctx := metadata.NewOutgoingContext(context.Background(), GRPCAccountCommonMetadata)
|
|
|
|
response, err := GRPCAccountClient.GetNEXPassword(ctx, &pb.GetNEXPasswordRequest{Pid: pid})
|
|
if err != nil {
|
|
Logger.Error(err.Error())
|
|
return "", nex.Errors.RendezVous.InvalidUsername
|
|
}
|
|
|
|
return response.Password, 0
|
|
}
|