mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-12 00:32:27 +08:00
fix(eventbus): update error handler to include topic information (#333)
* fix(eventbus): update error handler to include topic information - Modified error handler signature to accept topic string and error - Updated panic recovery logic to pass event topic to error handler - Adjusted SetErrorHandler method parameter signature - Updated example test to demonstrate new error handler usage - Enhanced error handling test to verify topic information * fix(eventbus): unit test
This commit is contained in:
@@ -189,8 +189,8 @@ func ExampleEventBus_GetListenersCount() {
|
||||
func ExampleEventBus_SetErrorHandler() {
|
||||
eb := NewEventBus[int]()
|
||||
|
||||
eb.SetErrorHandler(func(err error) {
|
||||
fmt.Println(err)
|
||||
eb.SetErrorHandler(func(topic string, err error) {
|
||||
fmt.Println(topic, err)
|
||||
})
|
||||
|
||||
eb.Subscribe("event1", func(eventData int) {
|
||||
@@ -200,7 +200,7 @@ func ExampleEventBus_SetErrorHandler() {
|
||||
eb.Publish(Event[int]{Topic: "event1", Payload: 1})
|
||||
|
||||
// Output:
|
||||
// error
|
||||
// event1 error
|
||||
}
|
||||
|
||||
func ExampleEventBus_GetAllListenersCount() {
|
||||
|
||||
Reference in New Issue
Block a user