Skip to content

Commit

Permalink
request: fix deferred Close without handling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Jul 23, 2024
1 parent fbab86f commit 565eac5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ func (c *RequestClient) Request(request RawRequest) (response RawResponse, err e

// Connect to the request socket
conn, err := net.DialUnix("unix", nil, c.conn)
defer conn.Close()
defer func() {
if e := conn.Close(); e == nil {
err = e
}
}()

if err != nil {
return nil, fmt.Errorf("error while connecting to socket: %w", err)
}
Expand Down Expand Up @@ -204,7 +209,7 @@ func (c *RequestClient) Request(request RawRequest) (response RawResponse, err e
}
}

return rbuf.Bytes(), nil
return rbuf.Bytes(), err
}

// Active window command, similar to 'hyprctl activewindow'.
Expand Down

0 comments on commit 565eac5

Please sign in to comment.