Skip to content

Commit

Permalink
Merge pull request #174 from dnephin/wrap-errors-in-watch
Browse files Browse the repository at this point in the history
Wrap a couple errors from filewatcher
  • Loading branch information
dnephin authored Jan 16, 2021
2 parents 22e9314 + 20fb1ea commit 6d0e310
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ func finishRun(opts *options, exec *testjson.Execution, exitErr error) error {
testjson.PrintSummary(opts.stdout, exec, opts.hideSummary.value)

if err := writeJUnitFile(opts, exec); err != nil {
return err
return fmt.Errorf("failed to write junit file: %w", err)
}
if err := postRunHook(opts, exec); err != nil {
return err
return fmt.Errorf("post run command failed: %w", err)
}
return exitErr
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (w *watchRuns) run(runOpts filewatcher.RunOptions) error {
if runOpts.Debug {
path, cleanup, err := delveInitFile(w.prevExec)
if err != nil {
return err
return fmt.Errorf("failed to write delve init file: %w", err)
}
defer cleanup()
o := delveOpts{
Expand All @@ -35,7 +35,7 @@ func (w *watchRuns) run(runOpts filewatcher.RunOptions) error {
initFilePath: path,
}
if err := runDelve(o); !isExitCoder(err) {
return err
return fmt.Errorf("delve failed: %w", err)
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions internal/filewatcher/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ func Watch(dirs []string, run func(opts RunOptions) error) error {
toWatch := findAllDirs(dirs, maxDepth)
watcher, err := fsnotify.NewWatcher()
if err != nil {
return err
return fmt.Errorf("failed to create file watcher: %w", err)
}
defer watcher.Close() // nolint: errcheck
defer watcher.Close() // nolint: errcheck // always returns nil error

fmt.Printf("Watching %v directories. Use Ctrl-c to to stop a run or exit.\n", len(toWatch))
for _, dir := range toWatch {
if err = watcher.Add(dir); err != nil {
return err
return fmt.Errorf("failed to watch directory %v: %w", dir, err)
}
}

Expand Down

0 comments on commit 6d0e310

Please sign in to comment.