From 21053ab734676f4190eb3ace3f55dadca89df947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Franke?= Date: Mon, 3 Apr 2023 12:31:56 +0200 Subject: [PATCH] Change error handling and logging --- services/eventhistory/pkg/service/service.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/eventhistory/pkg/service/service.go b/services/eventhistory/pkg/service/service.go index 26cc1fcdf1..7f972ad79e 100644 --- a/services/eventhistory/pkg/service/service.go +++ b/services/eventhistory/pkg/service/service.go @@ -90,14 +90,16 @@ func (eh *EventHistoryService) GetEventsForUser(ctx context.Context, req *ehsvc. } // Match all events that contains the user ID between two non-word characters. - userID := regexp.MustCompile(fmt.Sprintf(`\W%s\W`, req.UserID)) + userID, err := regexp.Compile(fmt.Sprintf(`\W%s\W`, req.UserID)) + if err != nil { + eh.log.Error().Err(err).Str("userID", req.UserID).Msg("could not compile regex") + return err + } for _, i := range idx { e, err := eh.store.Read(i) if err != nil { - if err != store.ErrNotFound { - eh.log.Error().Err(err).Str("eventid", i).Msg("could not read event") - } + eh.log.Error().Err(err).Str("eventid", i).Msg("could not read event") continue }