From 606c1ebda4b3e3f7c5e29acf8c1d1bea6dc56c5b Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 9 Oct 2020 13:42:15 +0100 Subject: [PATCH] Only return 500 on /send if a database error occurs --- federationapi/routing/send.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go index e2ab9b334..fe4295213 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -16,6 +16,7 @@ package routing import ( "context" + "database/sql" "encoding/json" "fmt" "net/http" @@ -234,17 +235,10 @@ func (t *txnReq) processTransaction(ctx context.Context) (*gomatrixserverlib.Res // we should stop processing the transaction, and returns false if it // is just some less serious error about a specific event. func isProcessingErrorFatal(err error) bool { - switch err.(type) { - case roomNotFoundError: - case *gomatrixserverlib.NotAllowed: - case missingPrevEventsError: - default: - switch err { - case context.Canceled: - case context.DeadlineExceeded: - default: - return true - } + switch err { + case sql.ErrConnDone: + case sql.ErrTxDone: + return true } return false }