mirror of
https://github.com/restic/restic.git
synced 2026-02-03 04:20:45 -05:00
Merge pull request #5528 from MichaelEischer/cleanup-fatalf-usage
Cleanup fatalf usage
This commit is contained in:
commit
eb13789b2b
9 changed files with 12 additions and 12 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue