From 7fbe49fd59ab01382fa4d40432f0fbbc138daf03 Mon Sep 17 00:00:00 2001 From: Patrick G Date: Sat, 22 Jul 2017 16:30:09 -0400 Subject: [PATCH] Workaround for possible panic from jpeg encoding --- book.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/book.go b/book.go index 9bd3a3ab..9dcffcab 100644 --- a/book.go +++ b/book.go @@ -48,7 +48,14 @@ type Book struct { } // NewBookFromFile creates a book object from a file -func NewBookFromFile(path, coverpath string) (*Book, error) { +func NewBookFromFile(path, coverpath string) (bk *Book, err error) { + defer func() { + if r := recover(); r != nil { + bk = nil + err = fmt.Errorf("Unknown error parsing book. Skipping. Error: %s", r) + } + }() + book := new(Book) book.Title = filepath.Base(path) book.Filepath = path