Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and improve incorrect error messages #21342

Merged
merged 5 commits into from
Oct 6, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions modules/options/static.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 The Gitea Authors. All rights reserved.
// Copyright 2016-2022 The Gitea Authors. All rights reserved.
delvh marked this conversation as resolved.
Show resolved Hide resolved
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -32,24 +32,23 @@ func Dir(name string) ([]string, error) {
customDir := path.Join(setting.CustomPath, "options", name)
isDir, err := util.IsDir(customDir)
if err != nil {
return []string{}, fmt.Errorf("Failed to check if custom directory %s is a directory. %v", err)
return []string{}, fmt.Errorf("failed to check if custom directory %s is a directory. %w", customDir, err)
delvh marked this conversation as resolved.
Show resolved Hide resolved
}
if isDir {
files, err := util.StatDir(customDir, true)
if err != nil {
return []string{}, fmt.Errorf("Failed to read custom directory. %v", err)
return []string{}, fmt.Errorf("failed to read custom directory %s. %w", customDir, err)
delvh marked this conversation as resolved.
Show resolved Hide resolved
}

result = append(result, files...)
}

files, err := AssetDir(name)
if err != nil {
return []string{}, fmt.Errorf("Failed to read embedded directory. %v", err)
return []string{}, fmt.Errorf("failed to read embedded directory %s. %w", name, err)
delvh marked this conversation as resolved.
Show resolved Hide resolved
}

result = append(result, files...)

return directories.AddAndGet(name, result), nil
}

Expand Down