Skip to content

Commit

Permalink
checking err!=nil in defer
Browse files Browse the repository at this point in the history
  • Loading branch information
parMaster committed Jul 9, 2024
1 parent bfa71fb commit 7603d66
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ func (z *ZoomClient) Authorize() error {
return err
}
defer func() {
err := resp.Body.Close()
log.Printf("[ERROR] failed to close response: %v", err)
if err := resp.Body.Close(); err != nil {
log.Printf("[ERROR] failed to close response: %v", err)
}
}()

if resp.StatusCode != http.StatusOK {
Expand Down Expand Up @@ -143,8 +144,9 @@ func (z *ZoomClient) GetIntervalMeetings(ctx context.Context, from, to time.Time
return nil, err
}
defer func() {
err := resp.Body.Close()
log.Printf("[ERROR] failed to close response: %v", err)
if err := resp.Body.Close(); err != nil {
log.Printf("[ERROR] failed to close response: %v", err)
}
}()

if resp.StatusCode != http.StatusOK {
Expand Down Expand Up @@ -259,8 +261,9 @@ func (z *ZoomClient) GetCloudStorageReport(from, to string) (*model.CloudRecordi
return nil, err
}
defer func() {
err := resp.Body.Close()
log.Printf("[ERROR] failed to close response: %v", err)
if err := resp.Body.Close(); err != nil {
log.Printf("[ERROR] failed to close response: %v", err)
}
}()

if resp.StatusCode != http.StatusOK {
Expand Down Expand Up @@ -320,8 +323,9 @@ func (z *ZoomClient) DeleteMeetingRecordings(meetingId string, delete bool) erro
return err
}
defer func() {
err := resp.Body.Close()
log.Printf("[ERROR] failed to close response: %v", err)
if err := resp.Body.Close(); err != nil {
log.Printf("[ERROR] failed to close response: %v", err)
}
}()

// 404 StatusNotFound happens when meeting is already deleted or trashed, so ignore the error
Expand Down

0 comments on commit 7603d66

Please sign in to comment.