summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-06-12 11:48:53 -0400
committerdemo <demo@antix1>2026-06-12 11:48:53 -0400
commitd63791257350c7cafe792d4ebfc625792e81ab65 (patch)
treeabefbfcb2aed946b085d7b83267b0918df646d77
parent104577455dcc0d45d0c0b6b9f07221beb1eb455f (diff)
refactor: return errors instead of using log.Fatal
-rw-r--r--run.go7
1 files 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)