Added TryFire

This allows handlers to return errors which will be returned to the caller.
Also replaced error returned from On with a panic.
This commit is contained in:
Leon Mika 2024-03-09 00:40:42 +00:00
parent a2269cd439
commit 91d1562e0e
3 changed files with 57 additions and 9 deletions

16
errors.go Normal file
View file

@ -0,0 +1,16 @@
package events
import "fmt"
type HandlerError struct {
topic string
errs []error
}
func (h HandlerError) Error() string {
return fmt.Sprintf("caught %d errors from topic '%v': %v", len(h.errs), h.topic, h.errs)
}
func (h HandlerError) Unwrap() []error {
return h.errs
}