From 00c83dfac79af6f03c677e187b5bce6817b2c2a7 Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Thu, 15 Sep 2022 10:49:45 +0200 Subject: [PATCH] Fix more error strings --- cmd/backup/archive.go | 2 +- cmd/backup/lock.go | 2 +- cmd/backup/notifications.go | 6 +++--- cmd/backup/script.go | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/backup/archive.go b/cmd/backup/archive.go index 46a9356..513df97 100644 --- a/cmd/backup/archive.go +++ b/cmd/backup/archive.go @@ -63,7 +63,7 @@ func compress(paths []string, outFilePath, subPath string) error { for _, p := range paths { if err := writeTarGz(p, tarWriter, prefix); err != nil { - return fmt.Errorf("compress error writing %s to archive: %w", p, err) + return fmt.Errorf("compress: error writing %s to archive: %w", p, err) } } diff --git a/cmd/backup/lock.go b/cmd/backup/lock.go index 2bb5a79..ccc578d 100644 --- a/cmd/backup/lock.go +++ b/cmd/backup/lock.go @@ -31,7 +31,7 @@ func (s *script) lock(lockfile string) (func() error, error) { for { acquired, err := fileLock.TryLock() if err != nil { - return noop, fmt.Errorf("lock: error trying lock: %w", err) + return noop, fmt.Errorf("lock: error trying to lock: %w", err) } if acquired { if s.encounteredLock { diff --git a/cmd/backup/notifications.go b/cmd/backup/notifications.go index 67b560c..ee1b6ea 100644 --- a/cmd/backup/notifications.go +++ b/cmd/backup/notifications.go @@ -36,16 +36,16 @@ func (s *script) notify(titleTemplate string, bodyTemplate string, err error) er titleBuf := &bytes.Buffer{} if err := s.template.ExecuteTemplate(titleBuf, titleTemplate, params); err != nil { - return fmt.Errorf("notifyFailure: error executing %s template: %w", titleTemplate, err) + return fmt.Errorf("notify: error executing %s template: %w", titleTemplate, err) } bodyBuf := &bytes.Buffer{} if err := s.template.ExecuteTemplate(bodyBuf, bodyTemplate, params); err != nil { - return fmt.Errorf("notifyFailure: error executing %s template: %w", bodyTemplate, err) + return fmt.Errorf("notify: error executing %s template: %w", bodyTemplate, err) } if err := s.sendNotification(titleBuf.String(), bodyBuf.String()); err != nil { - return fmt.Errorf("notifyFailure: error notifying: %w", err) + return fmt.Errorf("notify: error notifying: %w", err) } return nil } diff --git a/cmd/backup/script.go b/cmd/backup/script.go index b26fc05..c8be1c6 100644 --- a/cmd/backup/script.go +++ b/cmd/backup/script.go @@ -258,7 +258,7 @@ func (s *script) stopContainers() (func() error, error) { Quiet: true, }) if err != nil { - return noop, fmt.Errorf("stopContainersAndRun: error querying for containers: %w", err) + return noop, fmt.Errorf("stopContainers: error querying for containers: %w", err) } containerLabel := fmt.Sprintf( @@ -274,7 +274,7 @@ func (s *script) stopContainers() (func() error, error) { }) if err != nil { - return noop, fmt.Errorf("stopContainersAndRun: error querying for containers to stop: %w", err) + return noop, fmt.Errorf("stopContainers: error querying for containers to stop: %w", err) } if len(containersToStop) == 0 { @@ -301,7 +301,7 @@ func (s *script) stopContainers() (func() error, error) { var stopError error if len(stopErrors) != 0 { stopError = fmt.Errorf( - "stopContainersAndRun: %d error(s) stopping containers: %w", + "stopContainers: %d error(s) stopping containers: %w", len(stopErrors), utilities.Join(stopErrors...), ) @@ -338,7 +338,7 @@ func (s *script) stopContainers() (func() error, error) { } } if serviceMatch.ID == "" { - return fmt.Errorf("stopContainersAndRun: couldn't find service with name %s", serviceName) + return fmt.Errorf("stopContainers: couldn't find service with name %s", serviceName) } serviceMatch.Spec.TaskTemplate.ForceUpdate = 1 if _, err := s.cli.ServiceUpdate( @@ -352,7 +352,7 @@ func (s *script) stopContainers() (func() error, error) { if len(restartErrors) != 0 { return fmt.Errorf( - "stopContainersAndRun: %d error(s) restarting containers and services: %w", + "stopContainers: %d error(s) restarting containers and services: %w", len(restartErrors), utilities.Join(restartErrors...), ) @@ -381,7 +381,7 @@ func (s *script) createArchive() error { // copy before compressing guard against a situation where backup folder's content are still growing. s.registerHook(hookLevelPlumbing, func(error) error { if err := remove(backupSources); err != nil { - return fmt.Errorf("takeBackup: error removing snapshot: %w", err) + return fmt.Errorf("createArchive: error removing snapshot: %w", err) } s.logger.Infof("Removed snapshot `%s`.", backupSources) return nil