From ca5c88f14c51e8473dfb91616f6829733e7bc817 Mon Sep 17 00:00:00 2001 From: monirzadeh <25131576+Monirzadeh@users.noreply.github.com> Date: Sat, 19 Aug 2023 13:50:02 +0330 Subject: [PATCH] just log instead of fatal error --- epub_test.go | 6 +++--- example_test.go | 20 ++++++++++---------- write.go | 9 ++++----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/epub_test.go b/epub_test.go index c0e1b02..391db95 100644 --- a/epub_test.go +++ b/epub_test.go @@ -1083,7 +1083,7 @@ func unzipFile(sourceFilePath string, destDirPath string) error { } defer func() { if err := r.Close(); err != nil { - log.Fatal(err) + log.Println(err) } }() @@ -1095,7 +1095,7 @@ func unzipFile(sourceFilePath string, destDirPath string) error { } defer func() { if err := rc.Close(); err != nil { - log.Fatal(err) + log.Println(err) } }() @@ -1115,7 +1115,7 @@ func unzipFile(sourceFilePath string, destDirPath string) error { } defer func() { if err := w.Close(); err != nil { - log.Fatal(err) + log.Println(err) } }() diff --git a/example_test.go b/example_test.go index 9651361..657d408 100644 --- a/example_test.go +++ b/example_test.go @@ -15,13 +15,13 @@ func ExampleEpub_AddCSS() { // Add CSS css1Path, err := e.AddCSS("testdata/cover.css", "epub.css") if err != nil { - log.Fatal(err) + log.Println(err) } // The filename is optional css2Path, err := e.AddCSS("testdata/cover.css", "") if err != nil { - log.Fatal(err) + log.Println(err) } // Use the CSS in a section @@ -43,13 +43,13 @@ func ExampleEpub_AddFont() { // Add a font from a local file font1Path, err := e.AddFont("testdata/redacted-script-regular.ttf", "font.ttf") if err != nil { - log.Fatal(err) + log.Println(err) } // The filename is optional font2Path, err := e.AddFont("testdata/redacted-script-regular.ttf", "") if err != nil { - log.Fatal(err) + log.Println(err) } fmt.Println(font1Path) @@ -74,13 +74,13 @@ func ExampleEpub_AddImage() { // Add an image from a local file img1Path, err := e.AddImage("testdata/gophercolor16x16.png", "go-gopher.png") if err != nil { - log.Fatal(err) + log.Println(err) } // Add an image from a URL. The filename is optional img2Path, err := e.AddImage(testImageFromURLSource, "") if err != nil { - log.Fatal(err) + log.Println(err) } fmt.Println(img1Path) @@ -99,7 +99,7 @@ func ExampleEpub_AddSection() {
This is a paragraph.
` section1Path, err := e.AddSection(section1Body, "Section 1", "firstsection.xhtml", "") if err != nil { - log.Fatal(err) + log.Println(err) } // Link to the first section @@ -109,7 +109,7 @@ func ExampleEpub_AddSection() { // The title and filename are also optional section2Path, err := e.AddSection(section2Body, "", "", "") if err != nil { - log.Fatal(err) + log.Println(err) } fmt.Println(section1Path) @@ -128,7 +128,7 @@ func ExampleEpub_AddSubSection() {This is a paragraph.
` section1Path, err := e.AddSection(section1Body, "Section 1", "firstsection.xhtml", "") if err != nil { - log.Fatal(err) + log.Println(err) } // Link to the first section @@ -138,7 +138,7 @@ func ExampleEpub_AddSubSection() { // The title and filename are also optional section2Path, err := e.AddSubSection(section1Path, section2Body, "", "", "") if err != nil { - log.Fatal(err) + log.Println(err) } fmt.Println(section1Path) diff --git a/write.go b/write.go index cda0d4f..8a00ea7 100644 --- a/write.go +++ b/write.go @@ -296,8 +296,7 @@ func (e *Epub) writeEpub(rootEpubDir string, dst io.Writer) (int64, error) { } defer func() { if err := r.Close(); err != nil { - log.Fatal(err) - + log.Println(err) } }() @@ -313,14 +312,14 @@ func (e *Epub) writeEpub(rootEpubDir string, dst io.Writer) (int64, error) { mimetypeInfo, err := fs.Stat(filesystem, mimetypeFilePath) if err != nil { if err := z.Close(); err != nil { - log.Fatal(err) + log.Println(err) } return counter.Total, fmt.Errorf("unable to get FileInfo for mimetype file: %w", err) } err = addFileToZip(mimetypeFilePath, fileInfoToDirEntry(mimetypeInfo), nil) if err != nil { if err := z.Close(); err != nil { - log.Fatal(err) + log.Println(err) } return counter.Total, fmt.Errorf("unable to add mimetype file to EPUB: %w", err) } @@ -330,7 +329,7 @@ func (e *Epub) writeEpub(rootEpubDir string, dst io.Writer) (int64, error) { err = fs.WalkDir(filesystem, rootEpubDir, addFileToZip) if err != nil { if err := z.Close(); err != nil { - log.Fatal(err) + log.Println(err) } return counter.Total, fmt.Errorf("unable to add file to EPUB: %w", err) }