diff --git a/editor.py b/editor.py index 25d1dde..b31653c 100755 --- a/editor.py +++ b/editor.py @@ -25,7 +25,7 @@ def wrapENML(contentHTML): body += '%s' % contentHTML return body -def textToENML(content): +def textToENML(content, raise_ex=False): """ Create an ENML format of note. """ @@ -40,6 +40,9 @@ def textToENML(content): contentHTML = re.sub(r'\n', r'', contentHTML) return wrapENML(contentHTML) except: + if raise_ex: + raise Exception("Error while parsing text to html. Content must be an UTF-8 encode.") + logging.error("Error while parsing text to html. Content must be an UTF-8 encode.") out.failureMessage("Error while parsing text to html. Content must be an UTF-8 encode.") return tools.exit() diff --git a/gnsync.py b/gnsync.py index b871fa9..30ee773 100755 --- a/gnsync.py +++ b/gnsync.py @@ -177,7 +177,7 @@ def _get_file_content(self, path): Get file content. """ content = open(path, "r").read() - content = editor.textToENML(content) + content = editor.textToENML(content=content, raise_ex=True) if content is None: logger.warning("File {0}. Content must be an UTF-8 encode.".format(path))