From cded673af7577e29673779f57ac9a715af1fe6a3 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 17 Aug 2022 12:46:03 +0100 Subject: [PATCH] Report more useful error --- roomserver/internal/input/input_events.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/roomserver/internal/input/input_events.go b/roomserver/internal/input/input_events.go index fb6f91db2..948225778 100644 --- a/roomserver/internal/input/input_events.go +++ b/roomserver/internal/input/input_events.go @@ -112,9 +112,17 @@ func (r *Inputer) processRoomEvent( // can attempt to reprocess, in case we have learned something new // that will allow us to accept the event this time. wasRejected, werr := r.DB.IsEventRejected(ctx, event.EventID()) - if werr != nil && werr != sql.ErrNoRows { + switch { + case werr == sql.ErrNoRows: + // We haven't seen this event before so continue. + case werr != nil: + // Something has gone wrong trying to find out if we rejected + // this event already. + logger.WithError(werr).Errorf("Failed to check if event %q is already seen", event.EventID()) return werr - } else if werr == nil && !wasRejected { + case !wasRejected: + // We've seen this event before and it wasn't rejected so we + // should ignore it. logger.Debugf("Already processed event %q, ignoring", event.EventID()) return nil }