Skip to content

Commit a861357

Browse files
Improve the error handling in the sitemap.HierarchicalGenerator.ExtractLinks() method
1 parent dcc55ce commit a861357

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

registers/sitemap/hierarchical_generator.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sitemap
33
import (
44
"context"
55

6+
"github.com/pkg/errors"
67
urlutils "github.com/thewizardplusplus/go-crawler/url-utils"
78
)
89

@@ -21,10 +22,15 @@ func (generator HierarchicalGenerator) ExtractLinks(
2122
[]string,
2223
error,
2324
) {
24-
return urlutils.GenerateHierarchicalLinks(
25+
hierarchicalLinks, err := urlutils.GenerateHierarchicalLinks(
2526
baseLink,
2627
"sitemap.xml",
2728
urlutils.SanitizeBaseLink(generator.SanitizeLink),
2829
urlutils.WithMaximalHierarchyDepth(generator.MaximalDepth),
2930
)
31+
if err != nil {
32+
return nil, errors.Wrap(err, "unable to generate the hierarchical links")
33+
}
34+
35+
return hierarchicalLinks, nil
3036
}

0 commit comments

Comments
 (0)