Skip to content

Commit 62c6c34

Browse files
committed
Better error handling in search function
1 parent 1b03a5b commit 62c6c34

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/internal/function.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,18 @@ func returnFolderElementBySearchString(location string, displayDotFile bool, sea
143143
items, err := os.ReadDir(location)
144144
if err != nil {
145145
outPutLog("Return folder element function error", err)
146+
return []element{}
146147
}
147148

148149
folderElementMap := map[string]element{}
149150
fileAndDirectories := []string{}
150151

151152
for _, item := range items {
152-
fileInfo, _ := item.Info()
153-
if !displayDotFile && strings.HasPrefix(fileInfo.Name(), ".") {
153+
fileInfo, err := item.Info()
154+
if err != nil {
154155
continue
155156
}
156-
157-
if fileInfo == nil {
157+
if !displayDotFile && strings.HasPrefix(fileInfo.Name(), ".") {
158158
continue
159159
}
160160

0 commit comments

Comments
 (0)