Skip to content

Commit 68565f0

Browse files
committed
fine tune error messages
1 parent 13def4b commit 68565f0

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

modules/repository/init.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"context"
99
"fmt"
1010
"os"
11-
"path"
1211
"path/filepath"
1312
"sort"
1413
"strings"
@@ -55,26 +54,23 @@ func LoadRepoConfig() {
5554
for i, t := range types {
5655
files, err := options.Dir(t)
5756
if err != nil {
58-
log.Fatal("Failed to get %s files: %v", t, err)
57+
log.Fatal("Failed to list %s files: %v", t, err)
5958
}
60-
customPath := path.Join(setting.CustomPath, "options", t)
61-
isDir, err := util.IsDir(customPath)
62-
if err != nil {
63-
log.Fatal("Failed to get custom %s files: %v", t, err)
64-
}
65-
if isDir {
59+
customPath := filepath.Join(setting.CustomPath, "options", t)
60+
if isDir, err := util.IsDir(customPath); err != nil {
61+
log.Fatal("Failed to check custom %s dir: %v", t, err)
62+
} else if isDir {
6663
customFiles, err := util.StatDir(customPath)
6764
if err != nil {
68-
log.Fatal("Failed to get custom %s files: %v", t, err)
65+
log.Fatal("Failed to list custom %s files: %v", t, err)
6966
}
70-
7167
for _, f := range customFiles {
7268
stat, err := os.Stat(filepath.Join(customPath, f))
7369
if err != nil {
74-
log.Fatal("Failed to stat custom %s files: %v", t, err)
70+
log.Fatal("Failed to stat custom %s file %q: %v", t, f, err)
7571
}
72+
// give end users a chance to hide builtin options if they put an empty file in their custom directory
7673
if stat.Size() == 0 {
77-
// it's good to give end users a chance to hide builtin options if they put an empty file in their custom directory
7874
files = util.SliceRemoveAllFunc(files, func(s string) bool { return strings.EqualFold(s, f) })
7975
} else if !util.SliceContainsString(files, f, true) {
8076
files = append(files, f)

0 commit comments

Comments
 (0)