mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:21:54 +00:00
errors: standardize error wrapping for Fatal errors
* replace all occurences of `errors.Fatal(err.Error())` with `errors.Fatalf("%s", err)` so that the error wrapping is correct across the codebase
* updated the review comments
This commit is contained in:
@@ -250,7 +250,7 @@ func copyTree(ctx context.Context, srcRepo restic.Repository, dstRepo restic.Rep
|
||||
)
|
||||
bar.Done()
|
||||
if err != nil {
|
||||
return errors.Fatal(err.Error())
|
||||
return errors.Fatalf("%s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (opts *DiffOptions) AddFlags(f *pflag.FlagSet) {
|
||||
func loadSnapshot(ctx context.Context, be restic.Lister, repo restic.LoaderUnpacked, desc string) (*restic.Snapshot, string, error) {
|
||||
sn, subfolder, err := restic.FindSnapshot(ctx, be, repo, desc)
|
||||
if err != nil {
|
||||
return nil, "", errors.Fatal(err.Error())
|
||||
return nil, "", errors.Fatalf("%s", err)
|
||||
}
|
||||
return sn, subfolder, err
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func runInit(ctx context.Context, opts InitOptions, gopts GlobalOptions, args []
|
||||
PackSize: gopts.PackSize * 1024 * 1024,
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Fatal(err.Error())
|
||||
return errors.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
err = s.Init(ctx, version, gopts.password, chunkerPolynomial)
|
||||
|
||||
@@ -486,7 +486,7 @@ func OpenRepository(ctx context.Context, opts GlobalOptions) (*repository.Reposi
|
||||
NoExtraVerify: opts.NoExtraVerify,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Fatal(err.Error())
|
||||
return nil, errors.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
passwordTriesLeft := 1
|
||||
@@ -613,7 +613,7 @@ func innerOpen(ctx context.Context, s string, gopts GlobalOptions, opts options.
|
||||
|
||||
rt, err := backend.Transport(globalOptions.TransportOptions)
|
||||
if err != nil {
|
||||
return nil, errors.Fatal(err.Error())
|
||||
return nil, errors.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
// wrap the transport so that the throughput via HTTP is limited
|
||||
|
||||
@@ -567,7 +567,7 @@ func (plan *PrunePlan) Execute(ctx context.Context, printer progress.Printer) er
|
||||
_, err := Repack(ctx, repo, repo, plan.repackPacks, plan.keepBlobs, bar, printer.P)
|
||||
bar.Done()
|
||||
if err != nil {
|
||||
return errors.Fatal(err.Error())
|
||||
return errors.Fatalf("%s", err)
|
||||
}
|
||||
|
||||
// Also remove repacked packs
|
||||
|
||||
Reference in New Issue
Block a user