Skip to content

Commit 4740a65

Browse files
committed
Fix the wrapping of some errors
1 parent ad42697 commit 4740a65

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

git-sizer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func mainImplementation(args []string) error {
191191
if cpuprofile != "" {
192192
f, err := os.Create(cpuprofile)
193193
if err != nil {
194-
return fmt.Errorf("couldn't set up cpuprofile file: %s", err)
194+
return fmt.Errorf("couldn't set up cpuprofile file: %w", err)
195195
}
196196
pprof.StartCPUProfile(f)
197197
defer pprof.StopCPUProfile()
@@ -211,7 +211,7 @@ func mainImplementation(args []string) error {
211211
}
212212

213213
if repoErr != nil {
214-
return fmt.Errorf("couldn't open Git repository: %s", repoErr)
214+
return fmt.Errorf("couldn't open Git repository: %w", repoErr)
215215
}
216216

217217
if jsonOutput {
@@ -270,7 +270,7 @@ func mainImplementation(args []string) error {
270270

271271
historySize, err := sizes.ScanRepositoryUsingGraph(repo, rg, nameStyle, progress)
272272
if err != nil {
273-
return fmt.Errorf("error scanning repository: %s", err)
273+
return fmt.Errorf("error scanning repository: %w", err)
274274
}
275275

276276
if jsonOutput {
@@ -285,7 +285,7 @@ func mainImplementation(args []string) error {
285285
return fmt.Errorf("JSON version must be 1 or 2")
286286
}
287287
if err != nil {
288-
return fmt.Errorf("could not convert %v to json: %s", historySize, err)
288+
return fmt.Errorf("could not convert %v to json: %w", historySize, err)
289289
}
290290
fmt.Printf("%s\n", j)
291291
} else {

git/git.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func NewRepository(path string) (*Repository, error) {
9797
gitBin, err := findGitBin()
9898
if err != nil {
9999
return nil, fmt.Errorf(
100-
"could not find 'git' executable (is it in your PATH?): %v", err,
100+
"could not find 'git' executable (is it in your PATH?): %w", err,
101101
)
102102
}
103103

@@ -107,7 +107,7 @@ func NewRepository(path string) (*Repository, error) {
107107
switch err := err.(type) {
108108
case *exec.Error:
109109
return nil, fmt.Errorf(
110-
"could not run '%s': %v", gitBin, err.Err,
110+
"could not run '%s': %w", gitBin, err.Err,
111111
)
112112
case *exec.ExitError:
113113
return nil, fmt.Errorf(
@@ -124,7 +124,7 @@ func NewRepository(path string) (*Repository, error) {
124124
out, err = cmd.Output()
125125
if err != nil {
126126
return nil, fmt.Errorf(
127-
"could not run 'git rev-parse --git-path shallow': %s", err,
127+
"could not run 'git rev-parse --git-path shallow': %w", err,
128128
)
129129
}
130130
shallow := smartJoin(gitDir, string(bytes.TrimSpace(out)))

sizes/output.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func (t *Threshold) String() string {
262262
func (t *Threshold) Set(s string) error {
263263
v, err := strconv.ParseFloat(s, 64)
264264
if err != nil {
265-
return fmt.Errorf("error parsing floating-point value %q: %s", s, err)
265+
return fmt.Errorf("error parsing floating-point value %q: %w", s, err)
266266
}
267267
*t = Threshold(v)
268268
return nil

0 commit comments

Comments
 (0)