From 9108e1e50c62783087c8193a04317ee04376a850 Mon Sep 17 00:00:00 2001 From: fleaz Date: Thu, 23 May 2024 00:05:00 +0200 Subject: [PATCH] Add error handling --- main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 93481ce..13cdac7 100644 --- a/main.go +++ b/main.go @@ -23,10 +23,16 @@ func generatePreview(path string) Talk { imagePath := fmt.Sprintf("previews/%s.jpg", result[1]) mw := imagick.NewMagickWand() defer mw.Destroy() - mw.ReadImage(path) + err := mw.ReadImage(path) + if err != nil { + panic(err) + } mw.SetIteratorIndex(0) 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."} }