Skip to content

Commit

Permalink
Improve error output when failing initial scan upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgHaj committed Oct 5, 2023
1 parent 323ed16 commit 3371c61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/upload/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,20 @@ func (uploadBatch *uploadBatch) initUpload() ([]string, error) {
return files, nil
}

var entryFile string
var err error
for len(files) > 0 {
entryFile := files[0]
entryFile = files[0]
files = files[1:]
err := uploadBatch.uploadFile(entryFile)
err = uploadBatch.uploadFile(entryFile)
if err == nil {
printSuccessfulUpload(entryFile)

return files, nil
}
}

return files, errors.New("failed to initialize a scan due to badly formatted files")
return files, errors.New("failed to initialize a scan due to badly formatted files, initial upload file" + entryFile + " got the following error: " + err.Error())
}

type uploadedFile struct {
Expand Down
2 changes: 2 additions & 0 deletions internal/upload/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func TestInitUploadBadFile(t *testing.T) {

assert.Empty(t, files)
assert.ErrorContains(t, err, "failed to initialize a scan due to badly formatted files")
assert.ErrorContains(t, err, "filetestdata/misc/requirements.txt")
assert.ErrorContains(t, err, "tried to upload empty file")
}

func TestInitUpload(t *testing.T) {
Expand Down

0 comments on commit 3371c61

Please sign in to comment.