Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
remove all panic from code
Browse files Browse the repository at this point in the history
  • Loading branch information
Monirzadeh committed Aug 18, 2023
1 parent ec38e8f commit 1c5c9c1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions write.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ func (e *Epub) writeEpub(rootEpubDir string, dst io.Writer) (int64, error) {
}
defer func() {
if err := r.Close(); err != nil {
panic(err)
log.Fatal(err)

}
}()

Expand All @@ -312,14 +313,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 {
panic(err)
log.Fatal(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 {
panic(err)
log.Fatal(err)
}
return counter.Total, fmt.Errorf("unable to add mimetype file to EPUB: %w", err)
}
Expand All @@ -329,7 +330,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 {
panic(err)
log.Fatal(err)
}
return counter.Total, fmt.Errorf("unable to add file to EPUB: %w", err)
}
Expand Down

0 comments on commit 1c5c9c1

Please sign in to comment.