Add try except blocks where is needed

This commit is contained in:
Kiryl
2022-10-20 17:00:19 +03:00
parent 31d0d1a88a
commit a21a4b55b3
2 changed files with 33 additions and 21 deletions

View File

@@ -1,5 +1,6 @@
import json
import codecs
import logging
from src.book_solver import BookSolver
from src.util.helpers import BookLogger
@@ -30,11 +31,19 @@ class EpubBook(BookSolver):
json for LiveCarta platform
"""
html_preprocessor = HtmlPresetsProcessor(
logger=self.logger_object, preset_path="presets/epub_presets.json")
style_preprocessor = StyleReader()
html_processor = HtmlEpubProcessor(logger=self.logger_object,
html_preprocessor=html_preprocessor)
# Parses and cleans html, gets list of tags, gets footnotes
try:
html_preprocessor = HtmlPresetsProcessor(
logger=self.logger_object, preset_path="presets/epub_presets.json")
html_processor = HtmlEpubProcessor(logger=self.logger_object,
html_preprocessor=html_preprocessor)
except Exception as exc:
self.logger_object.log(
"Error has occurred while processing .html", logging.ERROR)
self.logger_object.log_error_to_main_log()
self.status_wrapper.set_error()
raise exc
json_converter = EpubConverter(
self.book_path, access=self.access, logger=self.logger_object,
style_processor=style_preprocessor, html_processor=html_processor)