From d63791257350c7cafe792d4ebfc625792e81ab65 Mon Sep 17 00:00:00 2001 From: demo Date: Fri, 12 Jun 2026 11:48:53 -0400 Subject: refactor: return errors instead of using log.Fatal --- run.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/run.go b/run.go index a1c64f7..266689d 100644 --- a/run.go +++ b/run.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io/fs" - "log" "net/url" "os" "runtime/pprof" @@ -48,16 +47,16 @@ func run(ctx context.Context, cmd *cli.Command) error { fmt.Println("Generating sitemap...") sitemap, err := toSitemap(seen, cmd.Int("depth"), cmd.Int("maxurls")) if err != nil { - log.Fatal(err) + return fmt.Errorf("creating sitemap: %w", err) } if err := os.Mkdir("xml", 0750); err != nil && !errors.Is(err, fs.ErrExist) { - log.Fatal(err) + return fmt.Errorf("making sitemap dir: %w", err) } xmlFilename := fmt.Sprintf("xml/%s.xml", u.Host) if err := os.WriteFile(xmlFilename, []byte(sitemap), 0666); err != nil { - log.Fatal(err) + return fmt.Errorf("writing sitemap: %w", err) } fmt.Printf("Wrote sitemap to %s\n", xmlFilename) -- cgit v1.2.3