Skip to content

Commit

Permalink
fix: joining errors
Browse files Browse the repository at this point in the history
  • Loading branch information
prit342 committed May 24, 2023
1 parent cb4bc34 commit 468ec86
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/certs/get_cert_pem.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ func (tc *TLSClient) TLSDial() (certs []*x509.Certificate, err error) {
}

defer func() {
if conn != nil {
if cerr := conn.Close(); cerr != nil && err == nil {
err = fmt.Errorf("error closing connection: %w", cerr)
}
if conn == nil { // ensure we don't panic
return
}
if closeErr := conn.Close(); closeErr != nil { // close the connection
err = errors.Join(err, closeErr) // return both the errors
}
}()

Expand Down

0 comments on commit 468ec86

Please sign in to comment.