Don't overwrite global err before return (#1293)

Signed-off-by: Olivier Charvin <git@olivier.pfad.fr>
This commit is contained in:
oliverpool 2020-08-25 14:11:52 +02:00 committed by GitHub
parent c8b873abc8
commit a4db43e096
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 69 additions and 64 deletions

View file

@ -95,9 +95,8 @@ func (s *OutputKeyChangeEventConsumer) updateOffset(msg *sarama.ConsumerMessage)
}
func (s *OutputKeyChangeEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
defer func() {
s.updateOffset(msg)
}()
defer s.updateOffset(msg)
var output api.DeviceMessage
if err := json.Unmarshal(msg.Value, &output); err != nil {
// If the message was invalid, log it and move on to the next message in the stream

View file

@ -455,13 +455,8 @@ func (d *Database) addPDUDeltaToResponse(
if err != nil {
return nil, err
}
var succeeded bool
defer func() {
txerr := sqlutil.EndTransaction(txn, &succeeded)
if err == nil && txerr != nil {
err = txerr
}
}()
succeeded := false
defer sqlutil.EndTransactionWithCheck(txn, &succeeded, &err)
stateFilter := gomatrixserverlib.DefaultStateFilter() // TODO: use filter provided in request
@ -641,13 +636,8 @@ func (d *Database) getResponseWithPDUsForCompleteSync(
if err != nil {
return
}
var succeeded bool
defer func() {
txerr := sqlutil.EndTransaction(txn, &succeeded)
if err == nil && txerr != nil {
err = txerr
}
}()
succeeded := false
defer sqlutil.EndTransactionWithCheck(txn, &succeeded, &err)
// Get the current sync position which we will base the sync response on.
toPos, err = d.syncPositionTx(ctx, txn)