mirror of
https://github.com/kovetskiy/mark.git
synced 2026-04-19 21:02:34 +00:00
- 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>
33 lines
583 B
Go
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...)
|
|
}
|