diff options
author | delvh <leon@kske.dev> | 2022-10-24 21:29:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 20:29:17 +0100 |
commit | 0ebb45cfe7606adf021ad359d6fbfcefc54360a5 (patch) | |
tree | 541b75d083213e93bbbfadbdc5d560c739543903 /modules | |
parent | 7c11a73833f3aa9783015e5e13871d3c298d3ef6 (diff) | |
download | gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.tar.gz gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.zip |
Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)
Found using
`find . -type f -name '*.go' -print -exec vim {} -c
':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;`
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules')
46 files changed, 169 insertions, 169 deletions
diff --git a/modules/avatar/avatar.go b/modules/avatar/avatar.go index 6ca75ed90f..2de77de009 100644 --- a/modules/avatar/avatar.go +++ b/modules/avatar/avatar.go @@ -30,7 +30,7 @@ func RandomImageSize(size int, data []byte) (image.Image, error) { // we use white as background, and use dark colors to draw blocks imgMaker, err := identicon.New(size, color.White, identicon.DarkColors...) if err != nil { - return nil, fmt.Errorf("identicon.New: %v", err) + return nil, fmt.Errorf("identicon.New: %w", err) } return imgMaker.Make(data), nil } @@ -46,7 +46,7 @@ func RandomImage(data []byte) (image.Image, error) { func Prepare(data []byte) (*image.Image, error) { imgCfg, _, err := image.DecodeConfig(bytes.NewReader(data)) if err != nil { - return nil, fmt.Errorf("DecodeConfig: %v", err) + return nil, fmt.Errorf("DecodeConfig: %w", err) } if imgCfg.Width > setting.Avatar.MaxWidth { return nil, fmt.Errorf("Image width is too large: %d > %d", imgCfg.Width, setting.Avatar.MaxWidth) @@ -57,7 +57,7 @@ func Prepare(data []byte) (*image.Image, error) { img, _, err := image.Decode(bytes.NewReader(data)) if err != nil { - return nil, fmt.Errorf("Decode: %v", err) + return nil, fmt.Errorf("Decode: %w", err) } if imgCfg.Width != imgCfg.Height { diff --git a/modules/doctor/authorizedkeys.go b/modules/doctor/authorizedkeys.go index d4ceef87c0..b3e9699a02 100644 --- a/modules/doctor/authorizedkeys.go +++ b/modules/doctor/authorizedkeys.go @@ -31,12 +31,12 @@ func checkAuthorizedKeys(ctx context.Context, logger log.Logger, autofix bool) e if err != nil { if !autofix { logger.Critical("Unable to open authorized_keys file. ERROR: %v", err) - return fmt.Errorf("Unable to open authorized_keys file. ERROR: %v", err) + return fmt.Errorf("Unable to open authorized_keys file. ERROR: %w", err) } logger.Warn("Unable to open authorized_keys. (ERROR: %v). Attempting to rewrite...", err) if err = asymkey_model.RewriteAllPublicKeys(); err != nil { logger.Critical("Unable to rewrite authorized_keys file. ERROR: %v", err) - return fmt.Errorf("Unable to rewrite authorized_keys file. ERROR: %v", err) + return fmt.Errorf("Unable to rewrite authorized_keys file. ERROR: %w", err) } } defer f.Close() @@ -57,7 +57,7 @@ func checkAuthorizedKeys(ctx context.Context, logger log.Logger, autofix bool) e regenerated := &bytes.Buffer{} if err := asymkey_model.RegeneratePublicKeys(ctx, regenerated); err != nil { logger.Critical("Unable to regenerate authorized_keys file. ERROR: %v", err) - return fmt.Errorf("Unable to regenerate authorized_keys file. ERROR: %v", err) + return fmt.Errorf("Unable to regenerate authorized_keys file. ERROR: %w", err) } scanner = bufio.NewScanner(regenerated) for scanner.Scan() { @@ -80,7 +80,7 @@ func checkAuthorizedKeys(ctx context.Context, logger log.Logger, autofix bool) e err = asymkey_model.RewriteAllPublicKeys() if err != nil { logger.Critical("Unable to rewrite authorized_keys file. ERROR: %v", err) - return fmt.Errorf("Unable to rewrite authorized_keys file. ERROR: %v", err) + return fmt.Errorf("Unable to rewrite authorized_keys file. ERROR: %w", err) } } return nil diff --git a/modules/doctor/breaking.go b/modules/doctor/breaking.go index 391c8e76c5..51122d9a61 100644 --- a/modules/doctor/breaking.go +++ b/modules/doctor/breaking.go @@ -47,7 +47,7 @@ func checkUserEmail(ctx context.Context, logger log.Logger, _ bool) error { } return nil }); err != nil { - return fmt.Errorf("iterateUserAccounts: %v", err) + return fmt.Errorf("iterateUserAccounts: %w", err) } if invalidUserCount == 0 { @@ -70,7 +70,7 @@ func checkUserName(ctx context.Context, logger log.Logger, _ bool) error { } return nil }); err != nil { - return fmt.Errorf("iterateUserAccounts: %v", err) + return fmt.Errorf("iterateUserAccounts: %w", err) } if invalidUserCount == 0 { diff --git a/modules/doctor/mergebase.go b/modules/doctor/mergebase.go index 4a10c72e6e..b279c453f7 100644 --- a/modules/doctor/mergebase.go +++ b/modules/doctor/mergebase.go @@ -78,7 +78,7 @@ func checkPRMergeBase(ctx context.Context, logger log.Logger, autofix bool) erro if autofix { if err := pr.UpdateCols("merge_base"); err != nil { logger.Critical("Failed to update merge_base. ERROR: %v", err) - return fmt.Errorf("Failed to update merge_base. ERROR: %v", err) + return fmt.Errorf("Failed to update merge_base. ERROR: %w", err) } } else { logger.Info("#%d onto %s in %s/%s: MergeBase should be %s but is %s", pr.Index, pr.BaseBranch, pr.BaseRepo.OwnerName, pr.BaseRepo.Name, oldMergeBase, pr.MergeBase) diff --git a/modules/doctor/misc.go b/modules/doctor/misc.go index 2d2bcb910d..277d66a177 100644 --- a/modules/doctor/misc.go +++ b/modules/doctor/misc.go @@ -43,7 +43,7 @@ func checkScriptType(ctx context.Context, logger log.Logger, autofix bool) error path, err := exec.LookPath(setting.ScriptType) if err != nil { logger.Critical("ScriptType \"%q\" is not on the current PATH. Error: %v", setting.ScriptType, err) - return fmt.Errorf("ScriptType \"%q\" is not on the current PATH. Error: %v", setting.ScriptType, err) + return fmt.Errorf("ScriptType \"%q\" is not on the current PATH. Error: %w", setting.ScriptType, err) } logger.Info("ScriptType %s is on the current PATH at %s", setting.ScriptType, path) return nil @@ -54,13 +54,13 @@ func checkHooks(ctx context.Context, logger log.Logger, autofix bool) error { results, err := repository.CheckDelegateHooks(repo.RepoPath()) if err != nil { logger.Critical("Unable to check delegate hooks for repo %-v. ERROR: %v", repo, err) - return fmt.Errorf("Unable to check delegate hooks for repo %-v. ERROR: %v", repo, err) + return fmt.Errorf("Unable to check delegate hooks for repo %-v. ERROR: %w", repo, err) } if len(results) > 0 && autofix { logger.Warn("Regenerated hooks for %s", repo.FullName()) if err := repository.CreateDelegateHooks(repo.RepoPath()); err != nil { logger.Critical("Unable to recreate delegate hooks for %-v. ERROR: %v", repo, err) - return fmt.Errorf("Unable to recreate delegate hooks for %-v. ERROR: %v", repo, err) + return fmt.Errorf("Unable to recreate delegate hooks for %-v. ERROR: %w", repo, err) } } for _, result := range results { diff --git a/modules/doctor/paths.go b/modules/doctor/paths.go index 22c095c227..5a27045457 100644 --- a/modules/doctor/paths.go +++ b/modules/doctor/paths.go @@ -29,7 +29,7 @@ func checkConfigurationFile(logger log.Logger, autofix bool, fileOpts configurat if os.IsNotExist(err) && autofix && fileOpts.IsDirectory { if err := os.MkdirAll(fileOpts.Path, 0o777); err != nil { logger.Error(" Directory does not exist and could not be created. ERROR: %v", err) - return fmt.Errorf("Configuration directory: \"%q\" does not exist and could not be created. ERROR: %v", fileOpts.Path, err) + return fmt.Errorf("Configuration directory: \"%q\" does not exist and could not be created. ERROR: %w", fileOpts.Path, err) } fi, err = os.Stat(fileOpts.Path) } @@ -37,7 +37,7 @@ func checkConfigurationFile(logger log.Logger, autofix bool, fileOpts configurat if err != nil { if fileOpts.Required { logger.Error(" Is REQUIRED but is not accessible. ERROR: %v", err) - return fmt.Errorf("Configuration file \"%q\" is not accessible but is required. Error: %v", fileOpts.Path, err) + return fmt.Errorf("Configuration file \"%q\" is not accessible but is required. Error: %w", fileOpts.Path, err) } logger.Warn(" NOTICE: is not accessible (Error: %v)", err) // this is a non-critical error @@ -46,14 +46,14 @@ func checkConfigurationFile(logger log.Logger, autofix bool, fileOpts configurat if fileOpts.IsDirectory && !fi.IsDir() { logger.Error(" ERROR: not a directory") - return fmt.Errorf("Configuration directory \"%q\" is not a directory. Error: %v", fileOpts.Path, err) + return fmt.Errorf("Configuration directory \"%q\" is not a directory. Error: %w", fileOpts.Path, err) } else if !fileOpts.IsDirectory && !fi.Mode().IsRegular() { logger.Error(" ERROR: not a regular file") - return fmt.Errorf("Configuration file \"%q\" is not a regular file. Error: %v", fileOpts.Path, err) + return fmt.Errorf("Configuration file \"%q\" is not a regular file. Error: %w", fileOpts.Path, err) } else if fileOpts.Writable { if err := isWritableDir(fileOpts.Path); err != nil { logger.Error(" ERROR: is required to be writable but is not writable: %v", err) - return fmt.Errorf("Configuration file \"%q\" is required to be writable but is not. Error: %v", fileOpts.Path, err) + return fmt.Errorf("Configuration file \"%q\" is required to be writable but is not. Error: %w", fileOpts.Path, err) } } return nil diff --git a/modules/git/blame.go b/modules/git/blame.go index 1653ecbf85..832b12213c 100644 --- a/modules/git/blame.go +++ b/modules/git/blame.go @@ -106,7 +106,7 @@ func (r *BlameReader) Close() error { _ = r.output.Close() if err := r.cmd.Wait(); err != nil { - return fmt.Errorf("Wait: %v", err) + return fmt.Errorf("Wait: %w", err) } return nil @@ -129,13 +129,13 @@ func createBlameReader(ctx context.Context, dir string, command ...string) (*Bla stdout, err := cmd.StdoutPipe() if err != nil { defer finished() - return nil, fmt.Errorf("StdoutPipe: %v", err) + return nil, fmt.Errorf("StdoutPipe: %w", err) } if err = cmd.Start(); err != nil { defer finished() _ = stdout.Close() - return nil, fmt.Errorf("Start: %v", err) + return nil, fmt.Errorf("Start: %w", err) } reader := bufio.NewReader(stdout) diff --git a/modules/git/diff.go b/modules/git/diff.go index 13ff6bd1e6..1a43d0dd4a 100644 --- a/modules/git/diff.go +++ b/modules/git/diff.go @@ -41,7 +41,7 @@ func GetReverseRawDiff(ctx context.Context, repoPath, commitID string, writer io Stdout: writer, Stderr: stderr, }); err != nil { - return fmt.Errorf("Run: %v - %s", err, stderr) + return fmt.Errorf("Run: %w - %s", err, stderr) } return nil } @@ -89,7 +89,7 @@ func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diff Stdout: writer, Stderr: stderr, }); err != nil { - return fmt.Errorf("Run: %v - %s", err, stderr) + return fmt.Errorf("Run: %w - %s", err, stderr) } return nil } diff --git a/modules/git/error.go b/modules/git/error.go index 40c4106414..ebfea8e702 100644 --- a/modules/git/error.go +++ b/modules/git/error.go @@ -116,7 +116,7 @@ func (err *ErrPushOutOfDate) Error() string { // Unwrap unwraps the underlying error func (err *ErrPushOutOfDate) Unwrap() error { - return fmt.Errorf("%v - %s", err.Err, err.StdErr) + return fmt.Errorf("%w - %s", err.Err, err.StdErr) } // ErrPushRejected represents an error if merging fails due to rejection from a hook @@ -139,7 +139,7 @@ func (err *ErrPushRejected) Error() string { // Unwrap unwraps the underlying error func (err *ErrPushRejected) Unwrap() error { - return fmt.Errorf("%v - %s", err.Err, err.StdErr) + return fmt.Errorf("%w - %s", err.Err, err.StdErr) } // GenerateMessage generates the remote message from the stderr diff --git a/modules/git/parse_gogit.go b/modules/git/parse_gogit.go index 409432c5d6..4a8dcfdf35 100644 --- a/modules/git/parse_gogit.go +++ b/modules/git/parse_gogit.go @@ -56,7 +56,7 @@ func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) { } id, err := NewIDFromString(string(data[pos : pos+40])) if err != nil { - return nil, fmt.Errorf("Invalid ls-tree output: %v", err) + return nil, fmt.Errorf("Invalid ls-tree output: %w", err) } entry.ID = id entry.gogitTreeEntry.Hash = id @@ -80,7 +80,7 @@ func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) { if data[pos] == '"' { entry.gogitTreeEntry.Name, err = strconv.Unquote(string(data[pos:end])) if err != nil { - return nil, fmt.Errorf("Invalid ls-tree output: %v", err) + return nil, fmt.Errorf("Invalid ls-tree output: %w", err) } } else { entry.gogitTreeEntry.Name = string(data[pos:end]) diff --git a/modules/git/pipeline/catfile.go b/modules/git/pipeline/catfile.go index 40dd2bca29..c1d4bd1665 100644 --- a/modules/git/pipeline/catfile.go +++ b/modules/git/pipeline/catfile.go @@ -33,7 +33,7 @@ func CatFileBatchCheck(ctx context.Context, shasToCheckReader *io.PipeReader, ca Stdout: catFileCheckWriter, Stderr: stderr, }); err != nil { - _ = catFileCheckWriter.CloseWithError(fmt.Errorf("git cat-file --batch-check [%s]: %v - %s", tmpBasePath, err, errbuf.String())) + _ = catFileCheckWriter.CloseWithError(fmt.Errorf("git cat-file --batch-check [%s]: %w - %s", tmpBasePath, err, errbuf.String())) } } @@ -51,7 +51,7 @@ func CatFileBatchCheckAllObjects(ctx context.Context, catFileCheckWriter *io.Pip Stderr: stderr, }); err != nil { log.Error("git cat-file --batch-check --batch-all-object [%s]: %v - %s", tmpBasePath, err, errbuf.String()) - err = fmt.Errorf("git cat-file --batch-check --batch-all-object [%s]: %v - %s", tmpBasePath, err, errbuf.String()) + err = fmt.Errorf("git cat-file --batch-check --batch-all-object [%s]: %w - %s", tmpBasePath, err, errbuf.String()) _ = catFileCheckWriter.CloseWithError(err) errChan <- err } @@ -71,7 +71,7 @@ func CatFileBatch(ctx context.Context, shasToBatchReader *io.PipeReader, catFile Stdin: shasToBatchReader, Stderr: stderr, }); err != nil { - _ = shasToBatchReader.CloseWithError(fmt.Errorf("git rev-list [%s]: %v - %s", tmpBasePath, err, errbuf.String())) + _ = shasToBatchReader.CloseWithError(fmt.Errorf("git rev-list [%s]: %w - %s", tmpBasePath, err, errbuf.String())) } } diff --git a/modules/git/pipeline/namerev.go b/modules/git/pipeline/namerev.go index 8356e70234..85ba7db23e 100644 --- a/modules/git/pipeline/namerev.go +++ b/modules/git/pipeline/namerev.go @@ -29,6 +29,6 @@ func NameRevStdin(ctx context.Context, shasToNameReader *io.PipeReader, nameRevS Stdin: shasToNameReader, Stderr: stderr, }); err != nil { - _ = shasToNameReader.CloseWithError(fmt.Errorf("git name-rev [%s]: %v - %s", tmpBasePath, err, errbuf.String())) + _ = shasToNameReader.CloseWithError(fmt.Errorf("git name-rev [%s]: %w - %s", tmpBasePath, err, errbuf.String())) } } diff --git a/modules/git/pipeline/revlist.go b/modules/git/pipeline/revlist.go index 5f62e85e7f..93142034ec 100644 --- a/modules/git/pipeline/revlist.go +++ b/modules/git/pipeline/revlist.go @@ -31,7 +31,7 @@ func RevListAllObjects(ctx context.Context, revListWriter *io.PipeWriter, wg *sy Stderr: stderr, }); err != nil { log.Error("git rev-list --objects --all [%s]: %v - %s", basePath, err, errbuf.String()) - err = fmt.Errorf("git rev-list --objects --all [%s]: %v - %s", basePath, err, errbuf.String()) + err = fmt.Errorf("git rev-list --objects --all [%s]: %w - %s", basePath, err, errbuf.String()) _ = revListWriter.CloseWithError(err) errChan <- err } @@ -50,7 +50,7 @@ func RevListObjects(ctx context.Context, revListWriter *io.PipeWriter, wg *sync. Stderr: stderr, }); err != nil { log.Error("git rev-list [%s]: %v - %s", tmpBasePath, err, errbuf.String()) - errChan <- fmt.Errorf("git rev-list [%s]: %v - %s", tmpBasePath, err, errbuf.String()) + errChan <- fmt.Errorf("git rev-list [%s]: %w - %s", tmpBasePath, err, errbuf.String()) } } diff --git a/modules/git/repo.go b/modules/git/repo.go index 575b686e29..8ba3ae4fda 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -90,7 +90,7 @@ func (repo *Repository) IsEmpty() (bool, error) { if err.Error() == "exit status 1" && errbuf.String() == "" { return true, nil } - return true, fmt.Errorf("check empty: %v - %s", err, errbuf.String()) + return true, fmt.Errorf("check empty: %w - %s", err, errbuf.String()) } return strings.TrimSpace(output.String()) == "", nil @@ -251,7 +251,7 @@ func Push(ctx context.Context, repoPath string, opts PushOptions) error { } if errbuf.Len() > 0 && err != nil { - return fmt.Errorf("%v - %s", err, errbuf.String()) + return fmt.Errorf("%w - %s", err, errbuf.String()) } return err diff --git a/modules/git/repo_attribute.go b/modules/git/repo_attribute.go index 60dc993dc2..d9c50be6f7 100644 --- a/modules/git/repo_attribute.go +++ b/modules/git/repo_attribute.go @@ -68,7 +68,7 @@ func (repo *Repository) CheckAttribute(opts CheckAttributeOpts) (map[string]map[ Stdout: stdOut, Stderr: stdErr, }); err != nil { - return nil, fmt.Errorf("failed to run check-attr: %v\n%s\n%s", err, stdOut.String(), stdErr.String()) + return nil, fmt.Errorf("failed to run check-attr: %w\n%s\n%s", err, stdOut.String(), stdErr.String()) } // FIXME: This is incorrect on versions < 1.8.5 diff --git a/modules/git/repo_compare.go b/modules/git/repo_compare.go index aad78370ff..7575b11658 100644 --- a/modules/git/repo_compare.go +++ b/modules/git/repo_compare.go @@ -62,7 +62,7 @@ func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string, // Add a temporary remote tmpRemote = strconv.FormatInt(time.Now().UnixNano(), 10) if err = repo.AddRemote(tmpRemote, basePath, false); err != nil { - return nil, fmt.Errorf("AddRemote: %v", err) + return nil, fmt.Errorf("AddRemote: %w", err) } defer func() { if err := repo.RemoveRemote(tmpRemote); err != nil { @@ -100,7 +100,7 @@ func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string, } compareInfo.Commits, err = repo.parsePrettyFormatLogToList(logs) if err != nil { - return nil, fmt.Errorf("parsePrettyFormatLogToList: %v", err) + return nil, fmt.Errorf("parsePrettyFormatLogToList: %w", err) } } else { compareInfo.Commits = []*Commit{} @@ -166,7 +166,7 @@ func (repo *Repository) GetDiffNumChangedFiles(base, head string, directComparis return w.numLines, nil } } - return 0, fmt.Errorf("%v: Stderr: %s", err, stderr) + return 0, fmt.Errorf("%w: Stderr: %s", err, stderr) } return w.numLines, nil } @@ -215,20 +215,20 @@ func parseDiffStat(stdout string) (numFiles, totalAdditions, totalDeletions int, numFiles, err = strconv.Atoi(groups[1]) if err != nil { - return 0, 0, 0, fmt.Errorf("unable to parse shortstat: %s. Error parsing NumFiles %v", stdout, err) + return 0, 0, 0, fmt.Errorf("unable to parse shortstat: %s. Error parsing NumFiles %w", stdout, err) } if len(groups[2]) != 0 { totalAdditions, err = strconv.Atoi(groups[2]) if err != nil { - return 0, 0, 0, fmt.Errorf("unable to parse shortstat: %s. Error parsing NumAdditions %v", stdout, err) + return 0, 0, 0, fmt.Errorf("unable to parse shortstat: %s. Error parsing NumAdditions %w", stdout, err) } } if len(groups[3]) != 0 { totalDeletions, err = strconv.Atoi(groups[3]) if err != nil { - return 0, 0, 0, fmt.Errorf("unable to parse shortstat: %s. Error parsing NumDeletions %v", stdout, err) + return 0, 0, 0, fmt.Errorf("unable to parse shortstat: %s. Error parsing NumDeletions %w", stdout, err) } } return numFiles, totalAdditions, totalDeletions, err diff --git a/modules/git/repo_gpg.go b/modules/git/repo_gpg.go index abbb349159..25188d07e3 100644 --- a/modules/git/repo_gpg.go +++ b/modules/git/repo_gpg.go @@ -18,7 +18,7 @@ func (gpgSettings *GPGSettings) LoadPublicKeyContent() error { "gpg -a --export", "gpg", "-a", "--export", gpgSettings.KeyID) if err != nil { - return fmt.Errorf("Unable to get default signing key: %s, %s, %v", gpgSettings.KeyID, stderr, err) + return fmt.Errorf("Unable to get default signing key: %s, %s, %w", gpgSettings.KeyID, stderr, err) } gpgSettings.PublicKeyContent = content return nil diff --git a/modules/git/repo_tag.go b/modules/git/repo_tag.go index fd0de7b3a1..8585d824f9 100644 --- a/modules/git/repo_tag.go +++ b/modules/git/repo_tag.go @@ -166,7 +166,7 @@ func parseTagRef(ref map[string]string) (tag *Tag, err error) { tag.ID, err = NewIDFromString(ref["objectname"]) if err != nil { - return nil, fmt.Errorf("parse objectname '%s': %v", ref["objectname"], err) + return nil, fmt.Errorf("parse objectname '%s': %w", ref["objectname"], err) } if tag.Type == "commit" { @@ -176,7 +176,7 @@ func parseTagRef(ref map[string]string) (tag *Tag, err error) { // annotated tag tag.Object, err = NewIDFromString(ref["object"]) if err != nil { - return nil, fmt.Errorf("parse object '%s': %v", ref["object"], err) + return nil, fmt.Errorf("parse object '%s': %w", ref["object"], err) } } diff --git a/modules/graceful/net_unix.go b/modules/graceful/net_unix.go index c7524a79db..0bb589e231 100644 --- a/modules/graceful/net_unix.go +++ b/modules/graceful/net_unix.go @@ -52,7 +52,7 @@ func getProvidedFDs() (savedErr error) { } n, err := strconv.Atoi(numFDs) if err != nil { - savedErr = fmt.Errorf("%s is not a number: %s. Err: %v", listenFDs, numFDs, err) + savedErr = fmt.Errorf("%s is not a number: %s. Err: %w", listenFDs, numFDs, err) return } @@ -81,7 +81,7 @@ func getProvidedFDs() (savedErr error) { } // If needed we can handle packetconns here. - savedErr = fmt.Errorf("Error getting provided socket fd %d: %v", i, err) + savedErr = fmt.Errorf("Error getting provided socket fd %d: %w", i, err) return } }) @@ -98,7 +98,7 @@ func CloseProvidedListeners() error { if err != nil { log.Error("Error in closing unused provided listener: %v", err) if returnableError != nil { - returnableError = fmt.Errorf("%v & %v", returnableError, err) + returnableError = fmt.Errorf("%v & %w", returnableError, err) } else { returnableError = err } @@ -198,7 +198,7 @@ func GetListenerUnix(network string, address *net.UnixAddr) (*net.UnixListener, // make a fresh listener if err := util.Remove(address.Name); err != nil && !os.IsNotExist(err) { - return nil, fmt.Errorf("Failed to remove unix socket %s: %v", address.Name, err) + return nil, fmt.Errorf("Failed to remove unix socket %s: %w", address.Name, err) } l, err := net.ListenUnix(network, address) @@ -208,7 +208,7 @@ func GetListenerUnix(network string, address *net.UnixAddr) (*net.UnixListener, fileMode := os.FileMode(setting.UnixSocketPermission) if err = os.Chmod(address.Name, fileMode); err != nil { - return nil, fmt.Errorf("Failed to set permission of unix socket to %s: %v", fileMode.String(), err) + return nil, fmt.Errorf("Failed to set permission of unix socket to %s: %w", fileMode.String(), err) } activeListeners = append(activeListeners, l) diff --git a/modules/hostmatcher/http.go b/modules/hostmatcher/http.go index 31430a9595..84cd2974ec 100644 --- a/modules/hostmatcher/http.go +++ b/modules/hostmatcher/http.go @@ -35,7 +35,7 @@ func NewDialContext(usage string, allowList, blockList *HostMatchList) func(ctx // in Control func, the addr was already resolved to IP:PORT format, there is no cost to do ResolveTCPAddr here tcpAddr, err := net.ResolveTCPAddr(network, ipAddr) if err != nil { - return fmt.Errorf("%s can only call HTTP servers via TCP, deny '%s(%s:%s)', err=%v", usage, host, network, ipAddr, err) + return fmt.Errorf("%s can only call HTTP servers via TCP, deny '%s(%s:%s)', err=%w", usage, host, network, ipAddr, err) } var blockedError error diff --git a/modules/indexer/code/bleve.go b/modules/indexer/code/bleve.go index f1298b01ed..3ea1c86178 100644 --- a/modules/indexer/code/bleve.go +++ b/modules/indexer/code/bleve.go @@ -199,7 +199,7 @@ func (b *BleveIndexer) addUpdate(ctx context.Context, batchWriter git.WriteClose return err } if size, err = strconv.ParseInt(strings.TrimSpace(stdout), 10, 64); err != nil { - return fmt.Errorf("Misformatted git cat-file output: %v", err) + return fmt.Errorf("Misformatted git cat-file output: %w", err) } } diff --git a/modules/indexer/code/elastic_search.go b/modules/indexer/code/elastic_search.go index 108a224675..dd3c9c9771 100644 --- a/modules/indexer/code/elastic_search.go +++ b/modules/indexer/code/elastic_search.go @@ -228,7 +228,7 @@ func (b *ElasticSearchIndexer) addUpdate(ctx context.Context, batchWriter git.Wr return nil, err } if size, err = strconv.ParseInt(strings.TrimSpace(stdout), 10, 64); err != nil { - return nil, fmt.Errorf("misformatted git cat-file output: %v", err) + return nil, fmt.Errorf("misformatted git cat-file output: %w", err) } } diff --git a/modules/indexer/issues/bleve.go b/modules/indexer/issues/bleve.go index c298b7de3e..dff1cf0c60 100644 --- a/modules/indexer/issues/bleve.go +++ b/modules/indexer/issues/bleve.go @@ -40,7 +40,7 @@ func indexerID(id int64) string { func idOfIndexerID(indexerID string) (int64, error) { id, err := strconv.ParseInt(indexerID, 36, 64) if err != nil { - return 0, fmt.Errorf("Unexpected indexer ID %s: %v", indexerID, err) + return 0, fmt.Errorf("Unexpected indexer ID %s: %w", indexerID, err) } return id, nil } diff --git a/modules/log/conn.go b/modules/log/conn.go index bd1d76d071..155f2866ca 100644 --- a/modules/log/conn.go +++ b/modules/log/conn.go @@ -108,7 +108,7 @@ func NewConn() LoggerProvider { func (log *ConnLogger) Init(jsonconfig string) error { err := json.Unmarshal([]byte(jsonconfig), log) if err != nil { - return fmt.Errorf("Unable to parse JSON: %v", err) + return fmt.Errorf("Unable to parse JSON: %w", err) } log.NewWriterLogger(&connWriter{ ReconnectOnMsg: log.ReconnectOnMsg, diff --git a/modules/log/console.go b/modules/log/console.go index 8c78add474..fc7c9b4967 100644 --- a/modules/log/console.go +++ b/modules/log/console.go @@ -54,7 +54,7 @@ func NewConsoleLogger() LoggerProvider { func (log *ConsoleLogger) Init(config string) error { err := json.Unmarshal([]byte(config), log) if err != nil { - return fmt.Errorf("Unable to parse JSON: %v", err) + return fmt.Errorf("Unable to parse JSON: %w", err) } if log.Stderr { log.NewWriterLogger(&nopWriteCloser{ diff --git a/modules/log/event.go b/modules/log/event.go index 41bb241da8..aebd156212 100644 --- a/modules/log/event.go +++ b/modules/log/event.go @@ -293,9 +293,9 @@ func (m *MultiChannelledLog) ReleaseReopen() error { for _, logger := range m.loggers { if err := logger.ReleaseReopen(); err != nil { if accumulatedErr == nil { - accumulatedErr = fmt.Errorf("Error whilst reopening: %s Error: %v", logger.GetName(), err) + accumulatedErr = fmt.Errorf("Error whilst reopening: %s Error: %w", logger.GetName(), err) } else { - accumulatedErr = fmt.Errorf("Error whilst reopening: %s Error: %v & %v", logger.GetName(), err, accumulatedErr) + accumulatedErr = fmt.Errorf("Error whilst reopening: %s Error: %v & %w", logger.GetName(), err, accumulatedErr) } } } diff --git a/modules/log/file.go b/modules/log/file.go index 8110a9587e..d0cba7817c 100644 --- a/modules/log/file.go +++ b/modules/log/file.go @@ -103,7 +103,7 @@ func NewFileLogger() LoggerProvider { // } func (log *FileLogger) Init(config string) error { if err := json.Unmarshal([]byte(config), log); err != nil { - return fmt.Errorf("Unable to parse JSON: %v", err) + return fmt.Errorf("Unable to parse JSON: %w", err) } if len(log.Filename) == 0 { return errors.New("config must have filename") @@ -145,7 +145,7 @@ func (log *FileLogger) initFd() error { fd := log.mw.fd finfo, err := fd.Stat() if err != nil { - return fmt.Errorf("get stat: %v", err) + return fmt.Errorf("get stat: %w", err) } log.maxsizeCursize = int(finfo.Size()) log.dailyOpenDate = time.Now().Day() @@ -178,7 +178,7 @@ func (log *FileLogger) DoRotate() error { // close fd before rename // Rename the file to its newfound home if err = util.Rename(log.Filename, fname); err != nil { - return fmt.Errorf("Rotate: %v", err) + return fmt.Errorf("Rotate: %w", err) } if log.Compress { @@ -187,7 +187,7 @@ func (log *FileLogger) DoRotate() error { // re-start logger if err = log.StartLogger(); err != nil { - return fmt.Errorf("Rotate StartLogger: %v", err) + return fmt.Errorf("Rotate StartLogger: %w", err) } go log.deleteOldLog() @@ -236,7 +236,7 @@ func (log *FileLogger) deleteOldLog() { if !info.IsDir() && info.ModTime().Unix() < (time.Now().Unix()-60*60*24*log.Maxdays) { if strings.HasPrefix(filepath.Base(path), filepath.Base(log.Filename)) { if err := util.Remove(path); err != nil { - returnErr = fmt.Errorf("Failed to remove %s: %v", path, err) + returnErr = fmt.Errorf("Failed to remove %s: %w", path, err) } } } diff --git a/modules/log/log.go b/modules/log/log.go index f805a36231..4303ecf4c0 100644 --- a/modules/log/log.go +++ b/modules/log/log.go @@ -219,9 +219,9 @@ func ReleaseReopen() error { logger := value.(*MultiChannelledLogger) if err := logger.ReleaseReopen(); err != nil { if accumulatedErr == nil { - accumulatedErr = fmt.Errorf("Error reopening %s: %v", key.(string), err) + accumulatedErr = fmt.Errorf("Error reopening %s: %w", key.(string), err) } else { - accumulatedErr = fmt.Errorf("Error reopening %s: %v & %v", key.(string), err, accumulatedErr) + accumulatedErr = fmt.Errorf("Error reopening %s: %v & %w", key.(string), err, accumulatedErr) } } return true diff --git a/modules/log/smtp.go b/modules/log/smtp.go index 1706517d6a..61af50b81a 100644 --- a/modules/log/smtp.go +++ b/modules/log/smtp.go @@ -60,7 +60,7 @@ func NewSMTPLogger() LoggerProvider { func (log *SMTPLogger) Init(jsonconfig string) error { err := json.Unmarshal([]byte(jsonconfig), log) if err != nil { - return fmt.Errorf("Unable to parse JSON: %v", err) + return fmt.Errorf("Unable to parse JSON: %w", err) } log.NewWriterLogger(&smtpWriter{ owner: log, diff --git a/modules/markup/external/external.go b/modules/markup/external/external.go index 23dd45ba0a..0eeb2d70a5 100644 --- a/modules/markup/external/external.go +++ b/modules/markup/external/external.go @@ -90,7 +90,7 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io. // write to temp file f, err := os.CreateTemp("", "gitea_input") if err != nil { - return fmt.Errorf("%s create temp file when rendering %s failed: %v", p.Name(), p.Command, err) + return fmt.Errorf("%s create temp file when rendering %s failed: %w", p.Name(), p.Command, err) } tmpPath := f.Name() defer func() { @@ -102,12 +102,12 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io. _, err = io.Copy(f, input) if err != nil { f.Close() - return fmt.Errorf("%s write data to temp file when rendering %s failed: %v", p.Name(), p.Command, err) + return fmt.Errorf("%s write data to temp file when rendering %s failed: %w", p.Name(), p.Command, err) } err = f.Close() if err != nil { - return fmt.Errorf("%s close temp file when rendering %s failed: %v", p.Name(), p.Command, err) + return fmt.Errorf("%s close temp file when rendering %s failed: %w", p.Name(), p.Command, err) } args = append(args, f.Name()) } @@ -137,7 +137,7 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io. process.SetSysProcAttribute(cmd) if err := cmd.Run(); err != nil { - return fmt.Errorf("%s render run command %s %v failed: %v", p.Name(), commands[0], args, err) + return fmt.Errorf("%s render run command %s %v failed: %w", p.Name(), commands[0], args, err) } return nil } diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go index 1c02f274ba..abbff1e435 100644 --- a/modules/markup/orgmode/orgmode.go +++ b/modules/markup/orgmode/orgmode.go @@ -110,7 +110,7 @@ func Render(ctx *markup.RenderContext, input io.Reader, output io.Writer) error res, err := org.New().Silent().Parse(input, "").Write(w) if err != nil { - return fmt.Errorf("orgmode.Render failed: %v", err) + return fmt.Errorf("orgmode.Render failed: %w", err) } _, err = io.Copy(output, strings.NewReader(res)) return err diff --git a/modules/mcaptcha/mcaptcha.go b/modules/mcaptcha/mcaptcha.go index b889cf423b..0c0fcce49d 100644 --- a/modules/mcaptcha/mcaptcha.go +++ b/modules/mcaptcha/mcaptcha.go @@ -21,7 +21,7 @@ func Verify(ctx context.Context, token string) (bool, error) { Token: token, }) if err != nil { - return false, fmt.Errorf("wasn't able to verify mCaptcha: %v", err) + return false, fmt.Errorf("wasn't able to verify mCaptcha: %w", err) } return valid, nil } diff --git a/modules/options/dynamic.go b/modules/options/dynamic.go index eeef11e8da..3739867580 100644 --- a/modules/options/dynamic.go +++ b/modules/options/dynamic.go @@ -32,12 +32,12 @@ func Dir(name string) ([]string, error) { isDir, err := util.IsDir(customDir) if err != nil { - return []string{}, fmt.Errorf("Unabe to check if custom directory %s is a directory. %v", customDir, err) + return []string{}, fmt.Errorf("Unabe to check if custom directory %s is a directory. %w", customDir, err) } 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. %w", err) } result = append(result, files...) @@ -47,12 +47,12 @@ func Dir(name string) ([]string, error) { isDir, err = util.IsDir(staticDir) if err != nil { - return []string{}, fmt.Errorf("unable to check if static directory %s is a directory. %v", staticDir, err) + return []string{}, fmt.Errorf("unable to check if static directory %s is a directory. %w", staticDir, err) } if isDir { files, err := util.StatDir(staticDir, true) if err != nil { - return []string{}, fmt.Errorf("Failed to read static directory. %v", err) + return []string{}, fmt.Errorf("Failed to read static directory. %w", err) } result = append(result, files...) diff --git a/modules/packages/nuget/symbol_extractor.go b/modules/packages/nuget/symbol_extractor.go index 13641ca6ef..9c04d7bfb4 100644 --- a/modules/packages/nuget/symbol_extractor.go +++ b/modules/packages/nuget/symbol_extractor.go @@ -75,7 +75,7 @@ func ExtractPortablePdb(r io.ReaderAt, size int64) (PortablePdbList, error) { id, err := ParseDebugHeaderID(buf) if err != nil { buf.Close() - return fmt.Errorf("Invalid PDB file: %v", err) + return fmt.Errorf("Invalid PDB file: %w", err) } if _, err := buf.Seek(0, io.SeekStart); err != nil { diff --git a/modules/private/hook.go b/modules/private/hook.go index 559019344e..e208c14378 100644 --- a/modules/private/hook.go +++ b/modules/private/hook.go @@ -163,7 +163,7 @@ func HookProcReceive(ctx context.Context, ownerName, repoName string, opts HookO req.Body(jsonBytes) resp, err := req.Response() if err != nil { - return nil, fmt.Errorf("Unable to contact gitea: %v", err.Error()) + return nil, fmt.Errorf("Unable to contact gitea: %w", err) } defer resp.Body.Close() @@ -189,7 +189,7 @@ func SetDefaultBranch(ctx context.Context, ownerName, repoName, branch string) e req.SetTimeout(60*time.Second, 60*time.Second) resp, err := req.Response() if err != nil { - return fmt.Errorf("Unable to contact gitea: %v", err) + return fmt.Errorf("Unable to contact gitea: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { @@ -213,7 +213,7 @@ func SSHLog(ctx context.Context, isErr bool, msg string) error { req.SetTimeout(60*time.Second, 60*time.Second) resp, err := req.Response() if err != nil { - return fmt.Errorf("unable to contact gitea: %v", err) + return fmt.Errorf("unable to contact gitea: %w", err) } defer resp.Body.Close() diff --git a/modules/queue/queue_wrapped.go b/modules/queue/queue_wrapped.go index 02f7818aa8..e581ba75f3 100644 --- a/modules/queue/queue_wrapped.go +++ b/modules/queue/queue_wrapped.go @@ -76,9 +76,9 @@ func (q *delayedStarter) setInternal(atShutdown func(func()), handle HandlerFunc i++ if q.maxAttempts > 0 && i > q.maxAttempts { if bs, ok := q.cfg.([]byte); ok { - return fmt.Errorf("unable to create queue %v for %s with cfg %s by max attempts: error: %v", q.underlying, q.name, string(bs), err) + return fmt.Errorf("unable to create queue %v for %s with cfg %s by max attempts: error: %w", q.underlying, q.name, string(bs), err) } - return fmt.Errorf("unable to create queue %v for %s with cfg %#v by max attempts: error: %v", q.underlying, q.name, q.cfg, err) + return fmt.Errorf("unable to create queue %v for %s with cfg %#v by max attempts: error: %w", q.underlying, q.name, q.cfg, err) } sleepTime := 100 * time.Millisecond if q.timeout > 0 && q.maxAttempts > 0 { diff --git a/modules/recaptcha/recaptcha.go b/modules/recaptcha/recaptcha.go index c6798f7117..91b70dc588 100644 --- a/modules/recaptcha/recaptcha.go +++ b/modules/recaptcha/recaptcha.go @@ -37,7 +37,7 @@ func Verify(ctx context.Context, response string) (bool, error) { req, err := http.NewRequestWithContext(ctx, http.MethodPost, util.URLJoin(setting.Service.RecaptchaURL, apiURL), strings.NewReader(post.Encode())) if err != nil { - return false, fmt.Errorf("Failed to create CAPTCHA request: %v", err) + return false, fmt.Errorf("Failed to create CAPTCHA request: %w", err) } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") diff --git a/modules/repository/commits.go b/modules/repository/commits.go index c4a69f4a01..7d6eec151f 100644 --- a/modules/repository/commits.go +++ b/modules/repository/commits.go @@ -78,7 +78,7 @@ func (pc *PushCommits) toAPIPayloadCommit(ctx context.Context, repoPath, repoLin fileStatus, err := git.GetCommitFileStatus(ctx, repoPath, commit.Sha1) if err != nil { - return nil, fmt.Errorf("FileStatus [commit_sha1: %s]: %v", commit.Sha1, err) + return nil, fmt.Errorf("FileStatus [commit_sha1: %s]: %w", commit.Sha1, err) } return &api.PayloadCommit{ diff --git a/modules/repository/create.go b/modules/repository/create.go index 966a6a2f21..1fec0335a2 100644 --- a/modules/repository/create.go +++ b/modules/repository/create.go @@ -37,7 +37,7 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re has, err := repo_model.IsRepositoryExist(ctx, u, repo.Name) if err != nil { - return fmt.Errorf("IsRepositoryExist: %v", err) + return fmt.Errorf("IsRepositoryExist: %w", err) } else if has { return repo_model.ErrRepoAlreadyExist{ Uname: u.Name, @@ -100,11 +100,11 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re // Remember visibility preference. u.LastRepoVisibility = repo.IsPrivate if err = user_model.UpdateUserCols(ctx, u, "last_repo_visibility"); err != nil { - return fmt.Errorf("UpdateUserCols: %v", err) + return fmt.Errorf("UpdateUserCols: %w", err) } if err = user_model.IncrUserRepoNum(ctx, u.ID); err != nil { - return fmt.Errorf("IncrUserRepoNum: %v", err) + return fmt.Errorf("IncrUserRepoNum: %w", err) } u.NumRepos++ @@ -112,40 +112,40 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re if u.IsOrganization() { teams, err := organization.FindOrgTeams(ctx, u.ID) if err != nil { - return fmt.Errorf("FindOrgTeams: %v", err) + return fmt.Errorf("FindOrgTeams: %w", err) } for _, t := range teams { if t.IncludesAllRepositories { if err := models.AddRepository(ctx, t, repo); err != nil { - return fmt.Errorf("AddRepository: %v", err) + return fmt.Errorf("AddRepository: %w", err) } } } if isAdmin, err := access_model.IsUserRepoAdmin(ctx, repo, doer); err != nil { - return fmt.Errorf("IsUserRepoAdmin: %v", err) + return fmt.Errorf("IsUserRepoAdmin: %w", err) } else if !isAdmin { // Make creator repo admin if it wasn't assigned automatically if err = addCollaborator(ctx, repo, doer); err != nil { - return fmt.Errorf("addCollaborator: %v", err) + return fmt.Errorf("addCollaborator: %w", err) } if err = repo_model.ChangeCollaborationAccessModeCtx(ctx, repo, doer.ID, perm.AccessModeAdmin); err != nil { - return fmt.Errorf("ChangeCollaborationAccessModeCtx: %v", err) + return fmt.Errorf("ChangeCollaborationAccessModeCtx: %w", err) } } } else if err = access_model.RecalculateAccesses(ctx, repo); err != nil { // Organization automatically called this in AddRepository method. - return fmt.Errorf("RecalculateAccesses: %v", err) + return fmt.Errorf("RecalculateAccesses: %w", err) } if setting.Service.AutoWatchNewRepos { if err = repo_model.WatchRepo(ctx, doer.ID, repo.ID, true); err != nil { - return fmt.Errorf("WatchRepo: %v", err) + return fmt.Errorf("WatchRepo: %w", err) } } if err = webhook.CopyDefaultWebhooksToRepo(ctx, repo.ID); err != nil { - return fmt.Errorf("CopyDefaultWebhooksToRepo: %v", err) + return fmt.Errorf("CopyDefaultWebhooksToRepo: %w", err) } return nil @@ -248,7 +248,7 @@ func CreateRepository(doer, u *user_model.User, opts CreateRepoOptions) (*repo_m return fmt.Errorf( "delete repo directory %s/%s failed(2): %v", u.Name, repo.Name, err2) } - return fmt.Errorf("initRepository: %v", err) + return fmt.Errorf("initRepository: %w", err) } // Initialize Issue Labels if selected @@ -256,12 +256,12 @@ func CreateRepository(doer, u *user_model.User, opts CreateRepoOptions) (*repo_m if err = InitializeLabels(ctx, repo.ID, opts.IssueLabels, false); err != nil { rollbackRepo = repo rollbackRepo.OwnerID = u.ID - return fmt.Errorf("InitializeLabels: %v", err) + return fmt.Errorf("InitializeLabels: %w", err) } } if err := CheckDaemonExportOK(ctx, repo); err != nil { - return fmt.Errorf("checkDaemonExportOK: %v", err) + return fmt.Errorf("checkDaemonExportOK: %w", err) } if stdout, _, err := git.NewCommand(ctx, "update-server-info"). @@ -270,7 +270,7 @@ func CreateRepository(doer, u *user_model.User, opts CreateRepoOptions) (*repo_m log.Error("CreateRepository(git update-server-info) in %v: Stdout: %s\nError: %v", repo, stdout, err) rollbackRepo = repo rollbackRepo.OwnerID = u.ID - return fmt.Errorf("CreateRepository(git update-server-info): %v", err) + return fmt.Errorf("CreateRepository(git update-server-info): %w", err) } return nil }); err != nil { @@ -290,12 +290,12 @@ func CreateRepository(doer, u *user_model.User, opts CreateRepoOptions) (*repo_m func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error { size, err := util.GetDirectorySize(repo.RepoPath()) if err != nil { - return fmt.Errorf("updateSize: %v", err) + return fmt.Errorf("updateSize: %w", err) } lfsSize, err := git_model.GetRepoLFSSize(ctx, repo.ID) if err != nil { - return fmt.Errorf("updateSize: GetLFSMetaObjects: %v", err) + return fmt.Errorf("updateSize: GetLFSMetaObjects: %w", err) } return repo_model.UpdateRepoSize(ctx, repo.ID, size+lfsSize) @@ -339,7 +339,7 @@ func UpdateRepository(ctx context.Context, repo *repo_model.Repository, visibili e := db.GetEngine(ctx) if _, err = e.ID(repo.ID).AllCols().Update(repo); err != nil { - return fmt.Errorf("update: %v", err) + return fmt.Errorf("update: %w", err) } if err = UpdateRepoSize(ctx, repo); err != nil { @@ -348,12 +348,12 @@ func UpdateRepository(ctx context.Context, repo *repo_model.Repository, visibili if visibilityChanged { if err = repo.GetOwner(ctx); err != nil { - return fmt.Errorf("getOwner: %v", err) + return fmt.Errorf("getOwner: %w", err) } if repo.Owner.IsOrganization() { // Organization repository need to recalculate access table when visibility is changed. if err = access_model.RecalculateTeamAccesses(ctx, repo, 0); err != nil { - return fmt.Errorf("recalculateTeamAccesses: %v", err) + return fmt.Errorf("recalculateTeamAccesses: %w", err) } } @@ -374,12 +374,12 @@ func UpdateRepository(ctx context.Context, repo *repo_model.Repository, visibili forkRepos, err := repo_model.GetRepositoriesByForkID(ctx, repo.ID) if err != nil { - return fmt.Errorf("getRepositoriesByForkID: %v", err) + return fmt.Errorf("getRepositoriesByForkID: %w", err) } for i := range forkRepos { forkRepos[i].IsPrivate = repo.IsPrivate || repo.Owner.Visibility == api.VisibleTypePrivate if err = UpdateRepository(ctx, forkRepos[i], true); err != nil { - return fmt.Errorf("updateRepository[%d]: %v", forkRepos[i].ID, err) + return fmt.Errorf("updateRepository[%d]: %w", forkRepos[i].ID, err) } } } diff --git a/modules/repository/generate.go b/modules/repository/generate.go index a69dd12a78..c5fd7d60bf 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -153,22 +153,22 @@ func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *r Depth: 1, Branch: templateRepo.DefaultBranch, }); err != nil { - return fmt.Errorf("git clone: %v", err) + return fmt.Errorf("git clone: %w", err) } if err := util.RemoveAll(path.Join(tmpDir, ".git")); err != nil { - return fmt.Errorf("remove git dir: %v", err) + return fmt.Errorf("remove git dir: %w", err) } // Variable expansion gt, err := checkGiteaTemplate(tmpDir) if err != nil { - return fmt.Errorf("checkGiteaTemplate: %v", err) + return fmt.Errorf("checkGiteaTemplate: %w", err) } if gt != nil { if err := util.Remove(gt.Path); err != nil { - return fmt.Errorf("remove .giteatemplate: %v", err) + return fmt.Errorf("remove .giteatemplate: %w", err) } // Avoid walking tree if there are no globs @@ -215,7 +215,7 @@ func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *r SetDescription(fmt.Sprintf("generateRepoCommit (git remote add): %s to %s", templateRepoPath, tmpDir)). RunStdString(&git.RunOpts{Dir: tmpDir, Env: env}); err != nil { log.Error("Unable to add %v as remote origin to temporary repo to %s: stdout %s\nError: %v", repo, tmpDir, stdout, err) - return fmt.Errorf("git remote add: %v", err) + return fmt.Errorf("git remote add: %w", err) } // set default branch based on whether it's specified in the newly generated repo or not @@ -230,7 +230,7 @@ func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *r func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *repo_model.Repository) (err error) { tmpDir, err := os.MkdirTemp(os.TempDir(), "gitea-"+repo.Name) if err != nil { - return fmt.Errorf("Failed to create temp dir for repository %s: %v", repo.RepoPath(), err) + return fmt.Errorf("Failed to create temp dir for repository %s: %w", repo.RepoPath(), err) } defer func() { @@ -240,12 +240,12 @@ func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *r }() if err = generateRepoCommit(ctx, repo, templateRepo, generateRepo, tmpDir); err != nil { - return fmt.Errorf("generateRepoCommit: %v", err) + return fmt.Errorf("generateRepoCommit: %w", err) } // re-fetch repo if repo, err = repo_model.GetRepositoryByIDCtx(ctx, repo.ID); err != nil { - return fmt.Errorf("getRepositoryByID: %v", err) + return fmt.Errorf("getRepositoryByID: %w", err) } // if there was no default branch supplied when generating the repo, use the default one from the template @@ -255,14 +255,14 @@ func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *r gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) if err != nil { - return fmt.Errorf("openRepository: %v", err) + return fmt.Errorf("openRepository: %w", err) } defer gitRepo.Close() if err = gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil { - return fmt.Errorf("setDefaultBranch: %v", err) + return fmt.Errorf("setDefaultBranch: %w", err) } if err = UpdateRepository(ctx, repo, false); err != nil { - return fmt.Errorf("updateRepository: %v", err) + return fmt.Errorf("updateRepository: %w", err) } return nil @@ -275,11 +275,11 @@ func GenerateGitContent(ctx context.Context, templateRepo, generateRepo *repo_mo } if err := UpdateRepoSize(ctx, generateRepo); err != nil { - return fmt.Errorf("failed to update size for repository: %v", err) + return fmt.Errorf("failed to update size for repository: %w", err) } if err := git_model.CopyLFS(ctx, generateRepo, templateRepo); err != nil { - return fmt.Errorf("failed to copy LFS: %v", err) + return fmt.Errorf("failed to copy LFS: %w", err) } return nil } @@ -342,14 +342,14 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ } if err = CheckDaemonExportOK(ctx, generateRepo); err != nil { - return generateRepo, fmt.Errorf("checkDaemonExportOK: %v", err) + return generateRepo, fmt.Errorf("checkDaemonExportOK: %w", err) } if stdout, _, err := git.NewCommand(ctx, "update-server-info"). SetDescription(fmt.Sprintf("GenerateRepository(git update-server-info): %s", repoPath)). RunStdString(&git.RunOpts{Dir: repoPath}); err != nil { log.Error("GenerateRepository(git update-server-info) in %v: Stdout: %s\nError: %v", generateRepo, stdout, err) - return generateRepo, fmt.Errorf("error in GenerateRepository(git update-server-info): %v", err) + return generateRepo, fmt.Errorf("error in GenerateRepository(git update-server-info): %w", err) } return generateRepo, nil diff --git a/modules/repository/hooks.go b/modules/repository/hooks.go index 7bc77552bd..4d7d294a92 100644 --- a/modules/repository/hooks.go +++ b/modules/repository/hooks.go @@ -123,30 +123,30 @@ func createDelegateHooks(repoPath string) (err error) { newHookPath := filepath.Join(hookDir, hookName+".d", "gitea") if err := os.MkdirAll(filepath.Join(hookDir, hookName+".d"), os.ModePerm); err != nil { - return fmt.Errorf("create hooks dir '%s': %v", filepath.Join(hookDir, hookName+".d"), err) + return fmt.Errorf("create hooks dir '%s': %w", filepath.Join(hookDir, hookName+".d"), err) } // WARNING: This will override all old server-side hooks if err = util.Remove(oldHookPath); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("unable to pre-remove old hook file '%s' prior to rewriting: %v ", oldHookPath, err) + return fmt.Errorf("unable to pre-remove old hook file '%s' prior to rewriting: %w ", oldHookPath, err) } if err = os.WriteFile(oldHookPath, []byte(hookTpls[i]), 0o777); err != nil { - return fmt.Errorf("write old hook file '%s': %v", oldHookPath, err) + return fmt.Errorf("write old hook file '%s': %w", oldHookPath, err) } if err = ensureExecutable(oldHookPath); err != nil { - return fmt.Errorf("Unable to set %s executable. Error %v", oldHookPath, err) + return fmt.Errorf("Unable to set %s executable. Error %w", oldHookPath, err) } if err = util.Remove(newHookPath); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("unable to pre-remove new hook file '%s' prior to rewriting: %v", newHookPath, err) + return fmt.Errorf("unable to pre-remove new hook file '%s' prior to rewriting: %w", newHookPath, err) } if err = os.WriteFile(newHookPath, []byte(giteaHookTpls[i]), 0o777); err != nil { - return fmt.Errorf("write new hook file '%s': %v", newHookPath, err) + return fmt.Errorf("write new hook file '%s': %w", newHookPath, err) } if err = ensureExecutable(newHookPath); err != nil { - return fmt.Errorf("Unable to set %s executable. Error %v", oldHookPath, err) + return fmt.Errorf("Unable to set %s executable. Error %w", oldHookPath, err) } } diff --git a/modules/repository/init.go b/modules/repository/init.go index 473729a599..65072a9599 100644 --- a/modules/repository/init.go +++ b/modules/repository/init.go @@ -91,7 +91,7 @@ func GetRepoInitFile(tp, name string) ([]byte, error) { func GetLabelTemplateFile(name string) ([][3]string, error) { data, err := GetRepoInitFile("label", name) if err != nil { - return nil, ErrIssueLabelTemplateLoad{name, fmt.Errorf("GetRepoInitFile: %v", err)} + return nil, ErrIssueLabelTemplateLoad{name, fmt.Errorf("GetRepoInitFile: %w", err)} } lines := strings.Split(string(data), "\n") @@ -232,13 +232,13 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, SetDescription(fmt.Sprintf("prepareRepoCommit (git clone): %s to %s", repoPath, tmpDir)). RunStdString(&git.RunOpts{Dir: "", Env: env}); err != nil { log.Error("Failed to clone from %v into %s: stdout: %s\nError: %v", repo, tmpDir, stdout, err) - return fmt.Errorf("git clone: %v", err) + return fmt.Errorf("git clone: %w", err) } // README data, err := GetRepoInitFile("readme", opts.Readme) if err != nil { - return fmt.Errorf("GetRepoInitFile[%s]: %v", opts.Readme, err) + return fmt.Errorf("GetRepoInitFile[%s]: %w", opts.Readme, err) } cloneLink := repo.CloneLink() @@ -256,7 +256,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, } if err = os.WriteFile(filepath.Join(tmpDir, "README.md"), []byte(res), 0o644); err != nil { - return fmt.Errorf("write README.md: %v", err) + return fmt.Errorf("write README.md: %w", err) } // .gitignore @@ -266,7 +266,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, for _, name := range names { data, err = GetRepoInitFile("gitignore", name) if err != nil { - return fmt.Errorf("GetRepoInitFile[%s]: %v", name, err) + return fmt.Errorf("GetRepoInitFile[%s]: %w", name, err) } buf.WriteString("# ---> " + name + "\n") buf.Write(data) @@ -275,7 +275,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, if buf.Len() > 0 { if err = os.WriteFile(filepath.Join(tmpDir, ".gitignore"), buf.Bytes(), 0o644); err != nil { - return fmt.Errorf("write .gitignore: %v", err) + return fmt.Errorf("write .gitignore: %w", err) } } } @@ -284,11 +284,11 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, if len(opts.License) > 0 { data, err = GetRepoInitFile("license", opts.License) if err != nil { - return fmt.Errorf("GetRepoInitFile[%s]: %v", opts.License, err) + return fmt.Errorf("GetRepoInitFile[%s]: %w", opts.License, err) } if err = os.WriteFile(filepath.Join(tmpDir, "LICENSE"), data, 0o644); err != nil { - return fmt.Errorf("write LICENSE: %v", err) + return fmt.Errorf("write LICENSE: %w", err) } } @@ -314,7 +314,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi SetDescription(fmt.Sprintf("initRepoCommit (git add): %s", tmpPath)). RunStdString(&git.RunOpts{Dir: tmpPath}); err != nil { log.Error("git add --all failed: Stdout: %s\nError: %v", stdout, err) - return fmt.Errorf("git add --all: %v", err) + return fmt.Errorf("git add --all: %w", err) } cmd := git.NewCommand(ctx, @@ -344,7 +344,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi SetDescription(fmt.Sprintf("initRepoCommit (git commit): %s", tmpPath)). RunStdString(&git.RunOpts{Dir: tmpPath, Env: env}); err != nil { log.Error("Failed to commit: %v: Stdout: %s\nError: %v", cmd.String(), stdout, err) - return fmt.Errorf("git commit: %v", err) + return fmt.Errorf("git commit: %w", err) } if len(defaultBranch) == 0 { @@ -355,7 +355,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi SetDescription(fmt.Sprintf("initRepoCommit (git push): %s", tmpPath)). RunStdString(&git.RunOpts{Dir: tmpPath, Env: InternalPushingEnvironment(u, repo)}); err != nil { log.Error("Failed to push back to HEAD: Stdout: %s\nError: %v", stdout, err) - return fmt.Errorf("git push: %v", err) + return fmt.Errorf("git push: %w", err) } return nil @@ -378,9 +378,9 @@ func checkInitRepository(ctx context.Context, owner, name string) (err error) { // Init git bare new repository. if err = git.InitRepository(ctx, repoPath, true); err != nil { - return fmt.Errorf("git.InitRepository: %v", err) + return fmt.Errorf("git.InitRepository: %w", err) } else if err = createDelegateHooks(repoPath); err != nil { - return fmt.Errorf("createDelegateHooks: %v", err) + return fmt.Errorf("createDelegateHooks: %w", err) } return nil } @@ -395,7 +395,7 @@ func initRepository(ctx context.Context, repoPath string, u *user_model.User, re if opts.AutoInit { tmpDir, err := os.MkdirTemp(os.TempDir(), "gitea-"+repo.Name) if err != nil { - return fmt.Errorf("Failed to create temp dir for repository %s: %v", repo.RepoPath(), err) + return fmt.Errorf("Failed to create temp dir for repository %s: %w", repo.RepoPath(), err) } defer func() { if err := util.RemoveAll(tmpDir); err != nil { @@ -404,19 +404,19 @@ func initRepository(ctx context.Context, repoPath string, u *user_model.User, re }() if err = prepareRepoCommit(ctx, repo, tmpDir, repoPath, opts); err != nil { - return fmt.Errorf("prepareRepoCommit: %v", err) + return fmt.Errorf("prepareRepoCommit: %w", err) } // Apply changes and commit. if err = initRepoCommit(ctx, tmpDir, repo, u, opts.DefaultBranch); err != nil { - return fmt.Errorf("initRepoCommit: %v", err) + return fmt.Errorf("initRepoCommit: %w", err) } } // Re-fetch the repository from database before updating it (else it would // override changes that were done earlier with sql) if repo, err = repo_model.GetRepositoryByIDCtx(ctx, repo.ID); err != nil { - return fmt.Errorf("getRepositoryByID: %v", err) + return fmt.Errorf("getRepositoryByID: %w", err) } if !opts.AutoInit { @@ -429,16 +429,16 @@ func initRepository(ctx context.Context, repoPath string, u *user_model.User, re repo.DefaultBranch = opts.DefaultBranch gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) if err != nil { - return fmt.Errorf("openRepository: %v", err) + return fmt.Errorf("openRepository: %w", err) } defer gitRepo.Close() if err = gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil { - return fmt.Errorf("setDefaultBranch: %v", err) + return fmt.Errorf("setDefaultBranch: %w", err) } } if err = UpdateRepository(ctx, repo, false); err != nil { - return fmt.Errorf("updateRepository: %v", err) + return fmt.Errorf("updateRepository: %w", err) } return nil diff --git a/modules/repository/repo.go b/modules/repository/repo.go index b01be322d2..de6de3bda4 100644 --- a/modules/repository/repo.go +++ b/modules/repository/repo.go @@ -70,7 +70,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, var err error if err = util.RemoveAll(repoPath); err != nil { - return repo, fmt.Errorf("Failed to remove %s: %v", repoPath, err) + return repo, fmt.Errorf("Failed to remove %s: %w", repoPath, err) } if err = git.Clone(ctx, opts.CloneAddr, repoPath, git.CloneRepoOptions{ @@ -79,7 +79,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, Timeout: migrateTimeout, SkipTLSVerify: setting.Migrations.SkipTLSVerify, }); err != nil { - return repo, fmt.Errorf("Clone: %v", err) + return repo, fmt.Errorf("Clone: %w", err) } if err := git.WriteCommitGraph(ctx, repoPath); err != nil { @@ -91,7 +91,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, wikiRemotePath := WikiRemoteURL(ctx, opts.CloneAddr) if len(wikiRemotePath) > 0 { if err := util.RemoveAll(wikiPath); err != nil { - return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err) + return repo, fmt.Errorf("Failed to remove %s: %w", wikiPath, err) } if err := git.Clone(ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{ @@ -103,7 +103,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, }); err != nil { log.Warn("Clone wiki: %v", err) if err := util.RemoveAll(wikiPath); err != nil { - return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err) + return repo, fmt.Errorf("Failed to remove %s: %w", wikiPath, err) } } else { if err := git.WriteCommitGraph(ctx, wikiPath); err != nil { @@ -118,25 +118,25 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, } if err = CheckDaemonExportOK(ctx, repo); err != nil { - return repo, fmt.Errorf("checkDaemonExportOK: %v", err) + return repo, fmt.Errorf("checkDaemonExportOK: %w", err) } if stdout, _, err := git.NewCommand(ctx, "update-server-info"). SetDescription(fmt.Sprintf("MigrateRepositoryGitData(git update-server-info): %s", repoPath)). RunStdString(&git.RunOpts{Dir: repoPath}); err != nil { log.Error("MigrateRepositoryGitData(git update-server-info) in %v: Stdout: %s\nError: %v", repo, stdout, err) - return repo, fmt.Errorf("error in MigrateRepositoryGitData(git update-server-info): %v", err) + return repo, fmt.Errorf("error in MigrateRepositoryGitData(git update-server-info): %w", err) } gitRepo, err := git.OpenRepository(ctx, repoPath) if err != nil { - return repo, fmt.Errorf("OpenRepository: %v", err) + return repo, fmt.Errorf("OpenRepository: %w", err) } defer gitRepo.Close() repo.IsEmpty, err = gitRepo.IsEmpty() if err != nil { - return repo, fmt.Errorf("git.IsEmpty: %v", err) + return repo, fmt.Errorf("git.IsEmpty: %w", err) } if !repo.IsEmpty { @@ -144,7 +144,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, // Try to get HEAD branch and set it as default branch. headBranch, err := gitRepo.GetHEADBranch() if err != nil { - return repo, fmt.Errorf("GetHEADBranch: %v", err) + return repo, fmt.Errorf("GetHEADBranch: %w", err) } if headBranch != nil { repo.DefaultBranch = headBranch.Name @@ -207,7 +207,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, } if err = repo_model.InsertMirror(ctx, &mirrorModel); err != nil { - return repo, fmt.Errorf("InsertOne: %v", err) + return repo, fmt.Errorf("InsertOne: %w", err) } repo.IsMirror = true @@ -231,11 +231,11 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User, func cleanUpMigrateGitConfig(configPath string) error { cfg, err := ini.Load(configPath) if err != nil { - return fmt.Errorf("open config file: %v", err) + return fmt.Errorf("open config file: %w", err) } cfg.DeleteSection("remote \"origin\"") if err = cfg.SaveToIndent(configPath, "\t"); err != nil { - return fmt.Errorf("save config file: %v", err) + return fmt.Errorf("save config file: %w", err) } return nil } @@ -244,22 +244,22 @@ func cleanUpMigrateGitConfig(configPath string) error { func CleanUpMigrateInfo(ctx context.Context, repo *repo_model.Repository) (*repo_model.Repository, error) { repoPath := repo.RepoPath() if err := createDelegateHooks(repoPath); err != nil { - return repo, fmt.Errorf("createDelegateHooks: %v", err) + return repo, fmt.Errorf("createDelegateHooks: %w", err) } if repo.HasWiki() { if err := createDelegateHooks(repo.WikiPath()); err != nil { - return repo, fmt.Errorf("createDelegateHooks.(wiki): %v", err) + return repo, fmt.Errorf("createDelegateHooks.(wiki): %w", err) } } _, _, err := git.NewCommand(ctx, "remote", "rm", "origin").RunStdString(&git.RunOpts{Dir: repoPath}) if err != nil && !strings.HasPrefix(err.Error(), "exit status 128 - fatal: No such remote ") { - return repo, fmt.Errorf("CleanUpMigrateInfo: %v", err) + return repo, fmt.Errorf("CleanUpMigrateInfo: %w", err) } if repo.HasWiki() { if err := cleanUpMigrateGitConfig(path.Join(repo.WikiPath(), "config")); err != nil { - return repo, fmt.Errorf("cleanUpMigrateGitConfig (wiki): %v", err) + return repo, fmt.Errorf("cleanUpMigrateGitConfig (wiki): %w", err) } } diff --git a/modules/repository/temp.go b/modules/repository/temp.go index 5947d29965..21af039469 100644 --- a/modules/repository/temp.go +++ b/modules/repository/temp.go @@ -27,12 +27,12 @@ func LocalCopyPath() string { func CreateTemporaryPath(prefix string) (string, error) { if err := os.MkdirAll(LocalCopyPath(), os.ModePerm); err != nil { log.Error("Unable to create localcopypath directory: %s (%v)", LocalCopyPath(), err) - return "", fmt.Errorf("Failed to create localcopypath directory %s: %v", LocalCopyPath(), err) + return "", fmt.Errorf("Failed to create localcopypath directory %s: %w", LocalCopyPath(), err) } basePath, err := os.MkdirTemp(LocalCopyPath(), prefix+".git") if err != nil { log.Error("Unable to create temporary directory: %s-*.git (%v)", prefix, err) - return "", fmt.Errorf("Failed to create dir %s-*.git: %v", prefix, err) + return "", fmt.Errorf("Failed to create dir %s-*.git: %w", prefix, err) } return basePath, nil diff --git a/modules/setting/database.go b/modules/setting/database.go index af4e780d76..4e55457395 100644 --- a/modules/setting/database.go +++ b/modules/setting/database.go @@ -137,7 +137,7 @@ func DBConnStr() (string, error) { return "", errors.New("this binary version does not build support for SQLite3") } if err := os.MkdirAll(path.Dir(Database.Path), os.ModePerm); err != nil { - return "", fmt.Errorf("Failed to create directories: %v", err) + return "", fmt.Errorf("Failed to create directories: %w", err) } journalMode := "" if Database.SQLiteJournalMode != "" { diff --git a/modules/setting/directory.go b/modules/setting/directory.go index 5dcdd89c04..2641510286 100644 --- a/modules/setting/directory.go +++ b/modules/setting/directory.go @@ -23,13 +23,13 @@ func PrepareAppDataPath() error { if os.IsNotExist(err) { err = os.MkdirAll(AppDataPath, os.ModePerm) if err != nil { - return fmt.Errorf("unable to create the APP_DATA_PATH directory: %q, Error: %v", AppDataPath, err) + return fmt.Errorf("unable to create the APP_DATA_PATH directory: %q, Error: %w", AppDataPath, err) } return nil } if err != nil { - return fmt.Errorf("unable to use APP_DATA_PATH %q. Error: %v", AppDataPath, err) + return fmt.Errorf("unable to use APP_DATA_PATH %q. Error: %w", AppDataPath, err) } if !st.IsDir() /* also works for symlink */ { |