Skip to content

Commit ee35dad

Browse files
authored
Merge pull request #789 from thockin/percent_w_for_errors
Replace all error %v with %w
2 parents 0971564 + a9b3f89 commit ee35dad

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,25 +1415,25 @@ func (git *repoSync) publishSymlink(ctx context.Context, worktree worktree) erro
14151415

14161416
// Make sure the link directory exists.
14171417
if err := os.MkdirAll(linkDir, defaultDirMode); err != nil {
1418-
return fmt.Errorf("error making symlink dir: %v", err)
1418+
return fmt.Errorf("error making symlink dir: %w", err)
14191419
}
14201420

14211421
// newDir is absolute, so we need to change it to a relative path. This is
14221422
// so it can be volume-mounted at another path and the symlink still works.
14231423
targetRelative, err := filepath.Rel(linkDir, targetPath.String())
14241424
if err != nil {
1425-
return fmt.Errorf("error converting to relative path: %v", err)
1425+
return fmt.Errorf("error converting to relative path: %w", err)
14261426
}
14271427

14281428
const tmplink = "tmp-link"
14291429
git.log.V(2).Info("creating tmp symlink", "dir", linkDir, "link", tmplink, "target", targetRelative)
14301430
if err := os.Symlink(targetRelative, filepath.Join(linkDir, tmplink)); err != nil {
1431-
return fmt.Errorf("error creating symlink: %v", err)
1431+
return fmt.Errorf("error creating symlink: %w", err)
14321432
}
14331433

14341434
git.log.V(2).Info("renaming symlink", "root", linkDir, "oldName", tmplink, "newName", linkFile)
14351435
if err := os.Rename(filepath.Join(linkDir, tmplink), git.link.String()); err != nil {
1436-
return fmt.Errorf("error replacing symlink: %v", err)
1436+
return fmt.Errorf("error replacing symlink: %w", err)
14371437
}
14381438

14391439
return nil
@@ -1451,7 +1451,7 @@ func (git *repoSync) removeWorktree(ctx context.Context, worktree worktree) erro
14511451
}
14521452
git.log.V(1).Info("removing worktree", "path", worktree.Path())
14531453
if err := os.RemoveAll(worktree.Path().String()); err != nil {
1454-
return fmt.Errorf("error removing directory: %v", err)
1454+
return fmt.Errorf("error removing directory: %w", err)
14551455
}
14561456
if _, _, err := git.Run(ctx, git.root, "worktree", "prune", "--verbose"); err != nil {
14571457
return err
@@ -2045,7 +2045,7 @@ func (git *repoSync) SetupDefaultGitConfigs(ctx context.Context) error {
20452045

20462046
for _, kv := range configs {
20472047
if _, _, err := git.Run(ctx, "", "config", "--global", kv.key, kv.val); err != nil {
2048-
return fmt.Errorf("error configuring git %q %q: %v", kv.key, kv.val, err)
2048+
return fmt.Errorf("error configuring git %q %q: %w", kv.key, kv.val, err)
20492049
}
20502050
}
20512051
return nil
@@ -2056,12 +2056,12 @@ func (git *repoSync) SetupDefaultGitConfigs(ctx context.Context) error {
20562056
func (git *repoSync) SetupExtraGitConfigs(ctx context.Context, configsFlag string) error {
20572057
configs, err := parseGitConfigs(configsFlag)
20582058
if err != nil {
2059-
return fmt.Errorf("can't parse --git-config flag: %v", err)
2059+
return fmt.Errorf("can't parse --git-config flag: %w", err)
20602060
}
20612061
git.log.V(1).Info("setting additional git configs", "configs", configs)
20622062
for _, kv := range configs {
20632063
if _, _, err := git.Run(ctx, "", "config", "--global", kv.key, kv.val); err != nil {
2064-
return fmt.Errorf("error configuring additional git configs %q %q: %v", kv.key, kv.val, err)
2064+
return fmt.Errorf("error configuring additional git configs %q %q: %w", kv.key, kv.val, err)
20652065
}
20662066
}
20672067

@@ -2122,12 +2122,12 @@ func parseGitConfigs(configsFlag string) ([]keyVal, error) {
21222122
if r == '"' {
21232123
cur.val, err = parseGitConfigQVal(ch)
21242124
if err != nil {
2125-
return nil, fmt.Errorf("key %q: %v", cur.key, err)
2125+
return nil, fmt.Errorf("key %q: %w", cur.key, err)
21262126
}
21272127
} else {
21282128
cur.val, err = parseGitConfigVal(r, ch)
21292129
if err != nil {
2130-
return nil, fmt.Errorf("key %q: %v", cur.key, err)
2130+
return nil, fmt.Errorf("key %q: %w", cur.key, err)
21312131
}
21322132
}
21332133
}

pkg/pid1/pid1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func sigchld(firstborn int) (bool, syscall.WaitStatus, error) {
8383
var status syscall.WaitStatus
8484
pid, err := syscall.Wait4(-1, &status, syscall.WNOHANG, nil)
8585
if err != nil {
86-
return false, 0, fmt.Errorf("wait4(): %v\n", err)
86+
return false, 0, fmt.Errorf("wait4(): %w\n", err)
8787
}
8888

8989
if pid == firstborn {

0 commit comments

Comments
 (0)