Only return 500 on /send if a database error occurs

This commit is contained in:
Neil Alexander 2020-10-09 13:42:15 +01:00
parent 1cd525ef0d
commit 606c1ebda4
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -16,6 +16,7 @@ package routing
import ( import (
"context" "context"
"database/sql"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -234,18 +235,11 @@ func (t *txnReq) processTransaction(ctx context.Context) (*gomatrixserverlib.Res
// we should stop processing the transaction, and returns false if it // we should stop processing the transaction, and returns false if it
// is just some less serious error about a specific event. // is just some less serious error about a specific event.
func isProcessingErrorFatal(err error) bool { func isProcessingErrorFatal(err error) bool {
switch err.(type) {
case roomNotFoundError:
case *gomatrixserverlib.NotAllowed:
case missingPrevEventsError:
default:
switch err { switch err {
case context.Canceled: case sql.ErrConnDone:
case context.DeadlineExceeded: case sql.ErrTxDone:
default:
return true return true
} }
}
return false return false
} }