Skip to content

Commit

Permalink
Warning instead of error (#356)
Browse files Browse the repository at this point in the history
Warning instead of error
  • Loading branch information
gauntface authored Dec 11, 2022
1 parent b36f4cd commit f450747
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion manipulations/opengraphimg/opengraphimg.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package opengraphimg

import (
"fmt"
"log"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -63,7 +64,8 @@ func Manipulator(runtime manipulations.Runtime, doc *html.Node) error {

img, err := getSuitableImg(runtime, c.Val)
if err != nil {
return err
log.Printf("Warning: Unable to find suitable image for %q: %v", c.Val, err)
continue
}

if img == nil {
Expand Down
4 changes: 2 additions & 2 deletions manipulations/opengraphimg/opengraphimg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func TestManipulator(t *testing.T) {
wantHTML: `<html><head><meta property="og:image"/></head><body></body></html>`,
},
{
description: "return error if getting images fails",
description: "do nothing if getting images fails",
findNodes: htmlparsing.FindNodesByTag,
doc: MustGetNode(t, `<meta property="og:image" content="/images/default-social.png" />`),
genimgsLookupSizes: func(s3 *s3.Client, conf *config.Config, imgPath string) ([]genimgs.GenImg, error) {
return nil, errInjected
},
wantError: errInjected,
wantHTML: `<html><head><meta property="og:image" content="/images/default-social.png"/></head><body></body></html>`,
},
{
description: "do nothing when no images",
Expand Down

0 comments on commit f450747

Please sign in to comment.