From 0c7febfa5ea823dcc02133209d7f41a746ccd3d2 Mon Sep 17 00:00:00 2001 From: Pavel Patrin Date: Sun, 4 Aug 2024 23:27:24 +0200 Subject: [PATCH] Typed signatures for event handlers. Signed-off-by: Pavel Patrin --- events.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/events.go b/events.go index 7c54f15..682e17b 100644 --- a/events.go +++ b/events.go @@ -96,7 +96,7 @@ func (em *events) callTypedHandler(handler reflect.Value, args []any) error { if !eventArgType.AssignableTo(handlerArgType) { return fmt.Errorf( "%w: type '%s' is not assignable to '%s' (index %d)", - HandlerTypeMismatchError, eventArgType, handlerArgType, index, + HandlerArgTypeMismatchError, eventArgType, handlerArgType, index, ) } handlerInArgs = append(handlerInArgs, reflect.ValueOf(eventArg)) @@ -163,5 +163,5 @@ func (e *event) Args() []any { return e.args } // anySliceType contains reflection type for any slice variable. var anySliceType = reflect.TypeOf((*[]any)(nil)).Elem() -// HandlerTypeMismatchError declares handler type mismatch error. -var HandlerTypeMismatchError = errors.New("handler type mismatch") +// HandlerArgTypeMismatchError declares handler argument type mismatch error. +var HandlerArgTypeMismatchError = errors.New("handler argument type mismatch")