Skip to content

Commit c965546

Browse files
authored
Return walkthrough error for build (#71)
1 parent 2670667 commit c965546

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

file.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
"github.com/pkg/errors"
99
)
1010

11+
const (
12+
WalkThroughError = "walking through file tree"
13+
)
14+
1115
// FileExists provides a clearer interface for checking if a file
1216
// exists.
1317
func FileExists(path string) bool {
@@ -106,7 +110,7 @@ func (b *FileListBuilder) Build() ([]string, error) {
106110
return nil, errors.New("cannot build file list without an include filter")
107111
}
108112
if err := filepath.Walk(b.WorkingDir, b.visitPath); err != nil {
109-
return nil, errors.Wrap(err, "building file list")
113+
return nil, errors.Wrap(err, WalkThroughError)
110114
}
111115

112116
return b.files, nil

file_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func TestFileListBuilder(t *testing.T) {
3535
}
3636
files, err := b.Build()
3737
require.Error(t, err)
38+
assert.Contains(t, err.Error(), WalkThroughError)
3839
assert.Empty(t, files)
3940
})
4041
})

0 commit comments

Comments
 (0)