mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-17 07:57:37 +08:00
fix: defer body.Close() before ReadAll to ensure it runs on read error
The defer was placed after io.ReadAll, so if ReadAll returned an error the body would not be closed. Move the defer before the read. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
a4ef890247
commit
9184e91268
@ -824,11 +824,12 @@ func newErrorStatusNotOK(request *gopencils.Resource) error {
|
||||
)
|
||||
}
|
||||
|
||||
output, _ := io.ReadAll(request.Raw.Body)
|
||||
defer func() {
|
||||
_ = request.Raw.Body.Close()
|
||||
}()
|
||||
|
||||
output, _ := io.ReadAll(request.Raw.Body)
|
||||
|
||||
return fmt.Errorf(
|
||||
"the Confluence API returned unexpected status: %v, "+
|
||||
"output: %q",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user