mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-08-02 08:04:39 -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.
30 lines
978 B
Go
30 lines
978 B
Go
package database
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
// ErrPIDNotFound is returned if a given PID is not found in the database
|
|
ErrPIDNotFound = errors.New("PID not found")
|
|
|
|
// ErrFriendRequestNotFound is returned if a given friend request is not found in the database
|
|
ErrFriendRequestNotFound = errors.New("Friend request not found")
|
|
|
|
// ErrFriendshipNotFound is returned if a given friendship is not found in the database
|
|
ErrFriendshipNotFound = errors.New("Friendship not found")
|
|
|
|
// ErrBlockListNotFound is returned if a given PID does not have a blacklist
|
|
ErrBlacklistNotFound = errors.New("Blacklist not found")
|
|
|
|
// ErrEmptyList is returned if a given PID returned an empty list on an operation
|
|
ErrEmptyList = errors.New("List is empty")
|
|
)
|
|
|
|
// PIDArrayToString converts an array of PIDs to a string usable in Postgres queries
|
|
func PIDArrayToString(array []uint32) string {
|
|
return strings.Trim(strings.Replace(fmt.Sprint(array), " ", ",", -1), "[]")
|
|
}
|