Skip to content

Commit

Permalink
message: handle Writer.Close errors in Entity.WriteTo
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Mar 6, 2024
1 parent dbb628d commit f7e55c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,13 @@ func (e *Entity) WriteTo(w io.Writer) error {
if err != nil {
return err
}
defer ew.Close()

return e.writeBodyTo(ew)
if err := e.writeBodyTo(ew); err != nil {
ew.Close()
return err
}

return ew.Close()
}

// WalkFunc is the type of the function called for each part visited by Walk.
Expand Down

0 comments on commit f7e55c4

Please sign in to comment.