mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-23 21:32:41 +08:00

- 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
35 lines
643 B
Go
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...)
|
|
}
|