From 7b679a2e84d52f4e78b6f4317c121e58c878e7af Mon Sep 17 00:00:00 2001 From: adnano Date: Sat, 24 Sep 2022 11:31:42 -0400 Subject: [PATCH] Simplify error handling for static content --- main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index b3525a0..ea78975 100644 --- a/main.go +++ b/main.go @@ -80,11 +80,7 @@ func (s *Site) runTask(task *Task) error { if task.StaticDir != "" { err := copyAll(task.StaticDir, task.OutputDir) if err != nil { - if os.IsNotExist(err) { - log.Printf("error building static_dir '%s': %s\n", task.StaticDir, err) - return nil - } - return err + return fmt.Errorf("failed to copy static content: %w", err) } } return nil @@ -93,6 +89,10 @@ func (s *Site) runTask(task *Task) error { func copyAll(srcDir, dstDir string) error { return filepath.Walk(srcDir, func(path string, info fs.FileInfo, err error) error { if err != nil { + if path == srcDir && info == nil { + // The source directory doesn't exist + return nil + } return err } if info.IsDir() {