Merge pull request #5528 from MichaelEischer/cleanup-fatalf-usage

Cleanup fatalf usage
This commit is contained in:
Michael Eischer
2025-10-01 20:17:30 +02:00
committed by GitHub
9 changed files with 12 additions and 12 deletions

View File

@@ -502,7 +502,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts GlobalOptions, ter
if opts.TimeStamp != "" {
timeStamp, err = time.ParseInLocation(TimeFormat, opts.TimeStamp, time.Local)
if err != nil {
return errors.Fatalf("error in time option: %v\n", err)
return errors.Fatalf("error in time option: %v", err)
}
}

View File

@@ -109,7 +109,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string, term ui.Ter
case "snapshot":
sn, _, err := restic.FindSnapshot(ctx, repo, repo, args[1])
if err != nil {
return errors.Fatalf("could not find snapshot: %v\n", err)
return errors.Fatalf("could not find snapshot: %v", err)
}
buf, err := json.MarshalIndent(sn, "", " ")
@@ -195,7 +195,7 @@ func runCat(ctx context.Context, gopts GlobalOptions, args []string, term ui.Ter
case "tree":
sn, subfolder, err := restic.FindSnapshot(ctx, repo, repo, args[1])
if err != nil {
return errors.Fatalf("could not find snapshot: %v\n", err)
return errors.Fatalf("could not find snapshot: %v", err)
}
bar := newIndexTerminalProgress(printer)

View File

@@ -102,7 +102,7 @@ func runInit(ctx context.Context, opts InitOptions, gopts GlobalOptions, args []
be, err := create(ctx, gopts.Repo, gopts, gopts.extended, printer)
if err != nil {
return errors.Fatalf("create repository at %s failed: %v\n", location.StripPassword(gopts.backends, gopts.Repo), err)
return errors.Fatalf("create repository at %s failed: %v", location.StripPassword(gopts.backends, gopts.Repo), err)
}
s, err := repository.New(be, repository.Options{
@@ -115,7 +115,7 @@ func runInit(ctx context.Context, opts InitOptions, gopts GlobalOptions, args []
err = s.Init(ctx, version, gopts.password, chunkerPolynomial)
if err != nil {
return errors.Fatalf("create key in repository at %s failed: %v\n", location.StripPassword(gopts.backends, gopts.Repo), err)
return errors.Fatalf("create key in repository at %s failed: %v", location.StripPassword(gopts.backends, gopts.Repo), err)
}
if !gopts.JSON {

View File

@@ -79,7 +79,7 @@ func addKey(ctx context.Context, repo *repository.Repository, gopts GlobalOption
id, err := repository.AddKey(ctx, repo, pw, opts.Username, opts.Hostname, repo.Key())
if err != nil {
return errors.Fatalf("creating new key failed: %v\n", err)
return errors.Fatalf("creating new key failed: %v", err)
}
err = switchToNewKeyAndRemoveIfBroken(ctx, repo, id, pw)

View File

@@ -74,7 +74,7 @@ func changePassword(ctx context.Context, repo *repository.Repository, gopts Glob
id, err := repository.AddKey(ctx, repo, pw, "", "", repo.Key())
if err != nil {
return errors.Fatalf("creating new key failed: %v\n", err)
return errors.Fatalf("creating new key failed: %v", err)
}
oldID := repo.KeyID()

View File

@@ -251,7 +251,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
progress.Finish()
if totalErrors > 0 {
return errors.Fatalf("There were %d errors\n", totalErrors)
return errors.Fatalf("There were %d errors", totalErrors)
}
if opts.Verify {
@@ -266,7 +266,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions,
return err
}
if totalErrors > 0 {
return errors.Fatalf("There were %d errors\n", totalErrors)
return errors.Fatalf("There were %d errors", totalErrors)
}
if !gopts.JSON {

View File

@@ -93,7 +93,7 @@ func (sma snapshotMetadataArgs) convert() (*snapshotMetadata, error) {
if sma.Time != "" {
t, err := time.ParseInLocation(TimeFormat, sma.Time, time.Local)
if err != nil {
return nil, errors.Fatalf("error in time option: %v\n", err)
return nil, errors.Fatalf("error in time option: %v", err)
}
timeStamp = &t
}

View File

@@ -171,7 +171,7 @@ func (opts *GlobalOptions) PreRun(needsPassword bool) error {
}
pwd, err := resolvePassword(opts, "RESTIC_PASSWORD")
if err != nil {
return errors.Fatal(fmt.Sprintf("Resolving password failed: %v\n", err))
return errors.Fatalf("Resolving password failed: %v", err)
}
opts.password = pwd
return nil

View File

@@ -87,7 +87,7 @@ func (fp *CommandReader) wait() error {
err := fp.cmd.Wait()
if err != nil {
// Use a fatal error to abort the snapshot.
return errors.Fatal(fmt.Errorf("command failed: %w", err).Error())
return errors.Fatalf("command failed: %v", err)
}
return nil
}