Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 7fbe49f

Browse files
committed
Workaround for possible panic from jpeg encoding
1 parent 3987c3a commit 7fbe49f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

book.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ type Book struct {
4848
}
4949

5050
// NewBookFromFile creates a book object from a file
51-
func NewBookFromFile(path, coverpath string) (*Book, error) {
51+
func NewBookFromFile(path, coverpath string) (bk *Book, err error) {
52+
defer func() {
53+
if r := recover(); r != nil {
54+
bk = nil
55+
err = fmt.Errorf("Unknown error parsing book. Skipping. Error: %s", r)
56+
}
57+
}()
58+
5259
book := new(Book)
5360
book.Title = filepath.Base(path)
5461
book.Filepath = path

0 commit comments

Comments
 (0)