Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error from WriteFilesToStream #61

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading