88
99 "github.com/po3rin/github_link_creator/config"
1010 "github.com/po3rin/github_link_creator/entity"
11+ l "github.com/po3rin/github_link_creator/lib/logger"
1112 "github.com/po3rin/img2circle"
1213)
1314
@@ -30,17 +31,26 @@ func ProcessingImg(ctx context.Context, r Repoitory, userName string, repoName s
3031 }
3132 cropper , err := img2circle .NewCropper (img2circle.Params {Src : ResizeImg (img )})
3233 if err != nil {
34+ l .Error (err )
3335 return nil , err
3436 }
3537 synthesizedImg , err := SynthesizeToBase (cropper .CropCircle ())
3638 if err != nil {
39+ l .Error (err )
3740 return nil , err
3841 }
3942
40- img = DrawText (synthesizedImg , config .Title , repo .Name )
41-
43+ img , err = DrawText (synthesizedImg , config .Title , repo .Name )
44+ if err != nil {
45+ l .Error (err )
46+ return nil , err
47+ }
4248 if len (repo .Description ) < 45 {
43- img = DrawText (img , config .FirstDescription , repo .Description )
49+ img , err = DrawText (img , config .FirstDescription , repo .Description )
50+ if err != nil {
51+ l .Error (err )
52+ return nil , err
53+ }
4454 } else {
4555 desc := repo .Description
4656 if len (repo .Description ) > 86 {
@@ -51,16 +61,31 @@ func ProcessingImg(ctx context.Context, r Repoitory, userName string, repoName s
5161 for _ , w := range words {
5262 firstline += w + " "
5363 if len (firstline ) >= 40 {
54- img = DrawText (img , config .FirstDescription , firstline )
64+ img , err = DrawText (img , config .FirstDescription , firstline )
65+ if err != nil {
66+ l .Error (err )
67+ return nil , err
68+ }
5569 secondline = strings .TrimPrefix (desc , firstline )
56- img = DrawText (img , config .SecondDescription , secondline )
70+ img , err = DrawText (img , config .SecondDescription , secondline )
71+ if err != nil {
72+ l .Error (err )
73+ return nil , err
74+ }
5775 break
5876 }
5977 }
6078 }
61-
62- img = DrawText (img , config .Star , strconv .Itoa (repo .Stars ))
63- img = DrawText (img , config .Fork , strconv .Itoa (repo .Forks ))
79+ img , err = DrawText (img , config .Star , strconv .Itoa (repo .Stars ))
80+ if err != nil {
81+ l .Error (err )
82+ return nil , err
83+ }
84+ img , err = DrawText (img , config .Fork , strconv .Itoa (repo .Forks ))
85+ if err != nil {
86+ l .Error (err )
87+ return nil , err
88+ }
6489
6590 return img , nil
6691}
0 commit comments