Skip to content

Commit

Permalink
fix(EventList): let remove return error
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-he committed Aug 4, 2024
1 parent 69abedc commit 24cfdac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/model/event_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type EventList struct {
}

// ...
func (l *EventList) RemoveEvent(event *Event) {
func (l *EventList) RemoveEvent(event *Event) error {
if event != nil {
index := -1
for i := range l.Events {
Expand All @@ -22,10 +22,11 @@ func (l *EventList) RemoveEvent(event *Event) {
}
}
if index == -1 {
panic(fmt.Sprintf("event %s not found for removal", event.String()))
return fmt.Errorf("event %s not found for removal", event.String())
}
l.Events = append(l.Events[:index], l.Events[index+1:]...)
}
return nil
}

func (l *EventList) GetEventByID(id EventID) *Event {
Expand Down

0 comments on commit 24cfdac

Please sign in to comment.