Better error message for panic

This commit is contained in:
Ian Gulliver
2023-06-17 13:35:55 -07:00
parent 4367a982d7
commit f1f007e351

View File

@@ -1,6 +1,9 @@
package event package event
import "time" import (
"fmt"
"time"
)
type Event struct { type Event struct {
start time.Time start time.Time
@@ -28,7 +31,7 @@ func NewEvent(eventType string, vals ...any) *Event {
func (ev *Event) Set(vals ...any) { func (ev *Event) Set(vals ...any) {
if len(vals)%2 != 0 { if len(vals)%2 != 0 {
panic(vals) panic(fmt.Sprintf("missing value for key in: %#v", vals))
} }
for i := 0; i < len(vals); i += 2 { for i := 0; i < len(vals); i += 2 {