mark/error_handler.go
iyz 7f5dfae904 fix: correct Errorf/Fatalf argument handling
- Fix incorrect argument passing to log.Errorf and log.Fatalf functions
- Remove debugging comments, temporary tests, and print statements
- Address linter warnings related to error logging
2025-04-02 14:37:48 +02:00

35 lines
643 B
Go

package main
import (
"fmt"
"github.com/reconquest/pkg/log"
)
type FatalErrorHandler struct {
ContinueOnError bool
}
func NewErrorHandler(continueOnError bool) *FatalErrorHandler {
return &FatalErrorHandler{
ContinueOnError: continueOnError,
}
}
func (h *FatalErrorHandler) Handle(err error, format string, args ...interface{}) {
if err == nil {
if h.ContinueOnError {
log.Error(fmt.Sprintf(format, args...))
return
}
log.Fatal(fmt.Sprintf(format, args...))
}
if h.ContinueOnError {
log.Errorf(err, format, args...)
return
}
log.Fatalf(err, format, args...)
}