package handlers

import (
	"daemonService/internal/models"
	"daemonService/internal/models/obtencionCodigos"
	"fmt"
)

func HandleError(s *models.ServiceModel, format string, args ...interface{}) error {
	errMsg := fmt.Sprintf(format, args...)
	if s.NotificationSender != nil {
		s.NotificationSender.SendNotification(
			fmt.Sprintf("Error en servicio %s", s.Name),
			errMsg,
		)
	}
	return fmt.Errorf(errMsg)
}

func HandleGetCodeError(s *obtencionCodigos.CuisServiceModel, format string, args ...interface{}) error {
	errMsg := fmt.Sprintf(format, args...)
	if s.NotificationSender != nil {
		s.NotificationSender.SendNotification(
			fmt.Sprintf("Error en servicio %s", s.Name),
			errMsg,
		)
	}
	return fmt.Errorf(errMsg)
}
