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:
parent
a2269cd439
commit
91d1562e0e
3 changed files with 57 additions and 9 deletions
16
errors.go
Normal file
16
errors.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue