diff --git a/ext/common.go b/ext/common.go index 1fc00ec..4ff6252 100644 --- a/ext/common.go +++ b/ext/common.go @@ -7,10 +7,18 @@ import ( func logError(l *slog.Logger, text string, err error) { if l == nil { - log.Printf("ERROR: %s: %s", text, err) + log.Printf("ERROR: %s: %s", text, err.Error()) return } - l.Error(text, "error", err) + l.Error(text, "error", err.Error()) +} + +func logDebug(l *slog.Logger, text string, args ...any) { + if l == nil { + // No logger? No debug. + return + } + l.Error(text, args...) } // ternary operator approximation. diff --git a/ext/dispatcher.go b/ext/dispatcher.go index de2527c..25202fa 100644 --- a/ext/dispatcher.go +++ b/ext/dispatcher.go @@ -285,8 +285,12 @@ func (d *Dispatcher) iterateOverHandlerGroups(b *gotgbot.Bot, ctx *Context) erro continue } + logDebug(d.Logger, "Matched handler on update", "handler", handler.Name()) + err := handler.HandleUpdate(b, ctx) if err != nil { + logDebug(d.Logger, "Update handling returned error", "handler", handler.Name(), "error", err.Error()) + if errors.Is(err, ContinueGroups) { // Continue handling current group. continue