Skip to content

Commit b001812

Browse files
authored
Fix and improve incorrect error messages (#21342)
L
1 parent 1294f6c commit b001812

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

modules/options/static.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Gitea Authors. All rights reserved.
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

@@ -32,24 +32,23 @@ func Dir(name string) ([]string, error) {
3232
customDir := path.Join(setting.CustomPath, "options", name)
3333
isDir, err := util.IsDir(customDir)
3434
if err != nil {
35-
return []string{}, fmt.Errorf("Failed to check if custom directory %s is a directory. %v", err)
35+
return []string{}, fmt.Errorf("unable to check if custom directory %q is a directory. %w", customDir, err)
3636
}
3737
if isDir {
3838
files, err := util.StatDir(customDir, true)
3939
if err != nil {
40-
return []string{}, fmt.Errorf("Failed to read custom directory. %v", err)
40+
return []string{}, fmt.Errorf("unable to read custom directory %q. %w", customDir, err)
4141
}
4242

4343
result = append(result, files...)
4444
}
4545

4646
files, err := AssetDir(name)
4747
if err != nil {
48-
return []string{}, fmt.Errorf("Failed to read embedded directory. %v", err)
48+
return []string{}, fmt.Errorf("unable to read embedded directory %q. %w", name, err)
4949
}
5050

5151
result = append(result, files...)
52-
5352
return directories.AddAndGet(name, result), nil
5453
}
5554

0 commit comments

Comments
 (0)