Files
mark/util/error_handler.go
Manuel Rüger a43f5fec2e refactor: modernize Go primitives
- Replace interface{} with any (Go 1.18) across confluence/api.go,
  macro/macro.go, util/cli.go, util/error_handler.go, includes/templates.go
- Replace sort.SliceStable with slices.SortStableFunc + cmp.Compare (Go 1.21)
  in attachment/attachment.go, consistent with existing slices usage
- Replace fmt.Errorf("%s", msg) with errors.New(msg) in mark.go

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-08 01:39:29 +02:00

33 lines
583 B
Go

package util
import (
"github.com/rs/zerolog/log"
)
type FatalErrorHandler struct {
ContinueOnError bool
}
func NewErrorHandler(continueOnError bool) *FatalErrorHandler {
return &FatalErrorHandler{
ContinueOnError: continueOnError,
}
}
func (h *FatalErrorHandler) Handle(err error, format string, args ...any) {
if err == nil {
if h.ContinueOnError {
log.Error().Msgf(format, args...)
return
}
log.Fatal().Msgf(format, args...)
}
if h.ContinueOnError {
log.Error().Err(err).Msgf(format, args...)
return
}
log.Fatal().Err(err).Msgf(format, args...)
}