Handle error on response.Body.Close()
This commit is contained in:
@@ -92,12 +92,14 @@ func (r CS3Repo) LoadAccount(ctx context.Context, id string, a *proto.Account) (
|
||||
return ¬FoundErr{"account", id}
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
var b []byte
|
||||
if err = dec.Decode(&b); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = resp.Body.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(b, &a)
|
||||
}
|
||||
|
||||
@@ -165,12 +167,14 @@ func (r CS3Repo) LoadGroup(ctx context.Context, id string, g *proto.Group) (err
|
||||
return ¬FoundErr{"group", id}
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
var b []byte
|
||||
if err = dec.Decode(&b); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = resp.Body.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(b, &g)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user