Add error handling

This commit is contained in:
fleaz 2024-05-23 00:05:00 +02:00
parent c930e9e92a
commit 9108e1e50c
No known key found for this signature in database
GPG key ID: AED15F8FDD04D083

10
main.go
View file

@ -23,10 +23,16 @@ func generatePreview(path string) Talk {
imagePath := fmt.Sprintf("previews/%s.jpg", result[1]) imagePath := fmt.Sprintf("previews/%s.jpg", result[1])
mw := imagick.NewMagickWand() mw := imagick.NewMagickWand()
defer mw.Destroy() defer mw.Destroy()
mw.ReadImage(path) err := mw.ReadImage(path)
if err != nil {
panic(err)
}
mw.SetIteratorIndex(0) mw.SetIteratorIndex(0)
mw.SetImageFormat("jpg") mw.SetImageFormat("jpg")
mw.WriteImage(imagePath) err = mw.WriteImage(imagePath)
if err != nil {
panic(err)
}
return Talk{Title: result[1], Preview: imagePath, Path: path, Description: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."} return Talk{Title: result[1], Preview: imagePath, Path: path, Description: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."}
} }