diff --git a/http/filestream/filestream.go b/http/filestream/filestream.go index a6b2ca2..ac9975e 100644 --- a/http/filestream/filestream.go +++ b/http/filestream/filestream.go @@ -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)) } } diff --git a/http/filestream/filestream_test.go b/http/filestream/filestream_test.go index 8d9e520..1173c13 100644 --- a/http/filestream/filestream_test.go +++ b/http/filestream/filestream_test.go @@ -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)