Skip to content

Commit

Permalink
Typed signatures for event handlers.
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Patrin <ppatrin@nvidia.com>
  • Loading branch information
pavelpatrin committed Aug 4, 2024
1 parent d004a40 commit 0c7febf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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")

0 comments on commit 0c7febf

Please sign in to comment.