Skip to content

Commit

Permalink
Return error from WriteFilesToStream (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi authored Apr 10, 2024
1 parent e45c025 commit 31bb808
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion http/filestream/filestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func WriteFilesToStream(multipartWriter *multipart.Writer, filesList []*FileInfo
defer ioutils.Close(multipartWriter, &err)
for _, file := range filesList {
if err = writeFile(multipartWriter, file); err != nil {
return writeErr(multipartWriter, file, err)
// Returning the error from writeFile with a possible error from the writeErr function
return errors.Join(err, writeErr(multipartWriter, file, err))
}
}

Expand Down
2 changes: 1 addition & 1 deletion http/filestream/filestream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestWriteFilesToStreamWithError(t *testing.T) {

// Call WriteFilesToStream and expect an error
err := WriteFilesToStream(multipartWriter, []*FileInfo{file})
require.NoError(t, err)
assert.Error(t, err)

multipartReader := multipart.NewReader(body, multipartWriter.Boundary())
form, err := multipartReader.ReadForm(10 * 1024)
Expand Down

0 comments on commit 31bb808

Please sign in to comment.