diff options
| author | demo <demo@antix1> | 2026-06-12 11:48:53 -0400 |
|---|---|---|
| committer | demo <demo@antix1> | 2026-06-12 11:48:53 -0400 |
| commit | d63791257350c7cafe792d4ebfc625792e81ab65 (patch) | |
| tree | abefbfcb2aed946b085d7b83267b0918df646d77 | |
| parent | 104577455dcc0d45d0c0b6b9f07221beb1eb455f (diff) | |
refactor: return errors instead of using log.Fatal
| -rw-r--r-- | run.go | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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) |
