Skip to content

Commit

Permalink
refacto: use %w instead of %s for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBigRoomXXL committed Sep 17, 2023
1 parent ec138aa commit 71506df
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
func tinyfeed(cmd *cobra.Command, args []string) error {
strdinArgs, err := stdinToArgs()
if err != nil {
return fmt.Errorf("could not parse stdin: %s", err)
return fmt.Errorf("fail to parse stdin: %w", err)
}

args = append(args, strdinArgs...)
Expand All @@ -41,7 +41,7 @@ func tinyfeed(cmd *cobra.Command, args []string) error {

err = printHTML(feeds, items)
if err != nil {
return fmt.Errorf("%s", err)
return fmt.Errorf("fail to output HTML: %w", err)
}
return nil
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func parseFeeds(url_list []string) []*gofeed.Feed {
func parseFeed(url string, fp *gofeed.Parser) *gofeed.Feed {
feed, err := fp.ParseURL(url)
if err != nil && !quiet {
fmt.Fprintf(os.Stderr, "WARNING: could not parse feed at %s: %s\n", url, err)
fmt.Fprintf(os.Stderr, "WARNING: fail to parse feed at %s: %s\n", url, err)
return nil
}
return feed
Expand Down Expand Up @@ -123,7 +123,7 @@ func printHTML(feeds []*gofeed.Feed, items []*gofeed.Item) error {
ParseFiles(templatePath)
}
if err != nil {
return fmt.Errorf("could not load HTML template: %s", err)
return fmt.Errorf("fail to load HTML template: %w", err)
}

imageCsp := "'self'"
Expand All @@ -149,7 +149,7 @@ func printHTML(feeds []*gofeed.Feed, items []*gofeed.Item) error {

err = ts.Execute(os.Stdout, data)
if err != nil {
return fmt.Errorf("could not render html template: %s", err)
return fmt.Errorf("fail to render HTML template: %w", err)
}

return nil
Expand Down

0 comments on commit 71506df

Please sign in to comment.