fix: change logger in veli handler
This commit is contained in:
parent
90f6921082
commit
c49e191657
|
|
@ -4,12 +4,12 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
||||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/virtualGame/veli"
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/services/virtualGame/veli"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetProviders godoc
|
// GetProviders godoc
|
||||||
|
|
@ -37,7 +37,10 @@ func (h *Handler) GetProviders(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
res, err := h.veliVirtualGameSvc.GetProviders(context.Background(), req)
|
res, err := h.veliVirtualGameSvc.GetProviders(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("GetProviders error:", err)
|
h.InternalServerErrorLogger().Error("Failed to [VeliGameHandler]GetProviders",
|
||||||
|
zap.Any("request", req),
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
|
||||||
Message: "Failed to retrieve providers",
|
Message: "Failed to retrieve providers",
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
|
|
@ -78,8 +81,10 @@ func (h *Handler) GetGamesByProvider(c *fiber.Ctx) error {
|
||||||
|
|
||||||
res, err := h.veliVirtualGameSvc.GetGames(context.Background(), req)
|
res, err := h.veliVirtualGameSvc.GetGames(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("GetGames error:", err)
|
h.InternalServerErrorLogger().Error("Failed to [VeliGameHandler]GetGames",
|
||||||
|
zap.Any("request", req),
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
// Handle provider disabled case specifically
|
// Handle provider disabled case specifically
|
||||||
if strings.Contains(err.Error(), "is disabled") {
|
if strings.Contains(err.Error(), "is disabled") {
|
||||||
return c.Status(fiber.StatusForbidden).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusForbidden).JSON(domain.ErrorResponse{
|
||||||
|
|
@ -89,7 +94,7 @@ func (h *Handler) GetGamesByProvider(c *fiber.Ctx) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback for other errors
|
// Fallback for other errors
|
||||||
return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
||||||
Message: "Failed to retrieve games",
|
Message: "Failed to retrieve games",
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
})
|
})
|
||||||
|
|
@ -141,8 +146,10 @@ func (h *Handler) StartGame(c *fiber.Ctx) error {
|
||||||
|
|
||||||
res, err := h.veliVirtualGameSvc.StartGame(context.Background(), req)
|
res, err := h.veliVirtualGameSvc.StartGame(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("StartGame error:", err)
|
h.InternalServerErrorLogger().Error("Failed to [VeliGameHandler]StartGame",
|
||||||
|
zap.Any("request", req),
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
// Handle provider disabled case specifically
|
// Handle provider disabled case specifically
|
||||||
if strings.Contains(err.Error(), "is disabled") {
|
if strings.Contains(err.Error(), "is disabled") {
|
||||||
return c.Status(fiber.StatusForbidden).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusForbidden).JSON(domain.ErrorResponse{
|
||||||
|
|
@ -193,8 +200,10 @@ func (h *Handler) StartDemoGame(c *fiber.Ctx) error {
|
||||||
|
|
||||||
res, err := h.veliVirtualGameSvc.StartDemoGame(context.Background(), req)
|
res, err := h.veliVirtualGameSvc.StartDemoGame(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("StartDemoGame error:", err)
|
h.InternalServerErrorLogger().Error("Failed to [VeliGameHandler]StartDemoGame",
|
||||||
|
zap.Any("request", req),
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
// Handle provider disabled case specifically
|
// Handle provider disabled case specifically
|
||||||
if strings.Contains(err.Error(), "is disabled") {
|
if strings.Contains(err.Error(), "is disabled") {
|
||||||
return c.Status(fiber.StatusForbidden).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusForbidden).JSON(domain.ErrorResponse{
|
||||||
|
|
@ -341,7 +350,10 @@ func (h *Handler) GetGamingActivity(c *fiber.Ctx) error {
|
||||||
|
|
||||||
resp, err := h.veliVirtualGameSvc.GetGamingActivity(c.Context(), req)
|
resp, err := h.veliVirtualGameSvc.GetGamingActivity(c.Context(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("GetGamingActivity error:", err)
|
h.InternalServerErrorLogger().Error("Failed to [VeliGameHandler]GetGamingActivity",
|
||||||
|
zap.Any("request", req),
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
||||||
Message: "Failed to retrieve gaming activity",
|
Message: "Failed to retrieve gaming activity",
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
|
|
@ -378,7 +390,10 @@ func (h *Handler) GetHugeWins(c *fiber.Ctx) error {
|
||||||
|
|
||||||
resp, err := h.veliVirtualGameSvc.GetHugeWins(c.Context(), req)
|
resp, err := h.veliVirtualGameSvc.GetHugeWins(c.Context(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("GetHugeWins error:", err)
|
h.InternalServerErrorLogger().Error("Failed to [VeliGameHandler]GetHugeWins",
|
||||||
|
zap.Any("request", req),
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusInternalServerError).JSON(domain.ErrorResponse{
|
||||||
Message: "Failed to retrieve huge wins",
|
Message: "Failed to retrieve huge wins",
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
|
|
@ -416,7 +431,10 @@ func (h *Handler) GetCreditBalances(c *fiber.Ctx) error {
|
||||||
|
|
||||||
res, err := h.veliVirtualGameSvc.GetCreditBalances(c.Context(), brandID)
|
res, err := h.veliVirtualGameSvc.GetCreditBalances(c.Context(), brandID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("GetCreditBalances error:", err)
|
h.InternalServerErrorLogger().Error("Failed to [VeliGameHandler]GetCreditBalances",
|
||||||
|
zap.String("brandID", brandID),
|
||||||
|
zap.Error(err),
|
||||||
|
)
|
||||||
return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
|
return c.Status(fiber.StatusBadGateway).JSON(domain.ErrorResponse{
|
||||||
Message: "Failed to fetch credit balances",
|
Message: "Failed to fetch credit balances",
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user