mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-18 04:13:10 -06:00
No overwriting of global err before return
This commit is contained in:
parent
37d117f2b7
commit
9c6af8a724
|
|
@ -82,7 +82,9 @@ func (r *Request) Do() (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer (func() { err = res.Body.Close() })()
|
defer (func() {
|
||||||
|
if err == nil { err = res.Body.Close() }
|
||||||
|
})()
|
||||||
|
|
||||||
if res.StatusCode != r.WantedStatusCode {
|
if res.StatusCode != r.WantedStatusCode {
|
||||||
return fmt.Errorf("incorrect status code. Expected: %d Got: %d", r.WantedStatusCode, res.StatusCode)
|
return fmt.Errorf("incorrect status code. Expected: %d Got: %d", r.WantedStatusCode, res.StatusCode)
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ func NewMatrixKey(matrixKeyPath string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
defer (func() {
|
defer (func() {
|
||||||
err = keyOut.Close()
|
if err == nil {err = keyOut.Close()}
|
||||||
})()
|
})()
|
||||||
|
|
||||||
err = pem.Encode(keyOut, &pem.Block{
|
err = pem.Encode(keyOut, &pem.Block{
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,10 @@ func WriteTempFile(reqReader io.Reader, maxFileSizeBytes config.FileSizeBytes, a
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer (func() { err = tmpFile.Close() })()
|
defer (func() {
|
||||||
|
if err == nil {err = tmpFile.Close()
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
// The amount of data read is limited to maxFileSizeBytes. At this point, if there is more data it will be truncated.
|
// The amount of data read is limited to maxFileSizeBytes. At this point, if there is more data it will be truncated.
|
||||||
limitedReader := io.LimitReader(reqReader, int64(maxFileSizeBytes))
|
limitedReader := io.LimitReader(reqReader, int64(maxFileSizeBytes))
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,9 @@ func (s *inviteStatements) updateInviteRetired(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer (func() { err = rows.Close() })()
|
defer (func() {
|
||||||
|
if err == nil {err = rows.Close()}
|
||||||
|
})()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var inviteEventID string
|
var inviteEventID string
|
||||||
if err := rows.Scan(&inviteEventID); err != nil {
|
if err := rows.Scan(&inviteEventID); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue