Only return 500 on /send if a database error occurs (#1503)

main
Neil Alexander 2020-10-09 15:06:43 +01:00 committed by GitHub
parent 2bd0449c5b
commit 4df7e345bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 11 deletions

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,17 +235,10 @@ 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) { switch err {
case roomNotFoundError: case sql.ErrConnDone:
case *gomatrixserverlib.NotAllowed: case sql.ErrTxDone:
case missingPrevEventsError: return true
default:
switch err {
case context.Canceled:
case context.DeadlineExceeded:
default:
return true
}
} }
return false return false
} }