diff --git a/jrnl/messages.py b/jrnl/messages.py index 639b1199..c91f789a 100644 --- a/jrnl/messages.py +++ b/jrnl/messages.py @@ -150,6 +150,10 @@ class MsgText(Enum): Headings increased past H6 on export - {date} {title} """ + YamlMustBeDirectory = """ + YAML export must be to a directory, not a single file + """ + # --- Import --- # ImportSummary = """ {count} imported to {journal_name} journal diff --git a/jrnl/plugins/yaml_exporter.py b/jrnl/plugins/yaml_exporter.py index 8983d2e4..0f820207 100644 --- a/jrnl/plugins/yaml_exporter.py +++ b/jrnl/plugins/yaml_exporter.py @@ -6,12 +6,13 @@ import os import re import sys -from jrnl.color import ERROR_COLOR -from jrnl.color import RESET_COLOR -from jrnl.color import WARNING_COLOR - from .text_exporter import TextExporter +from jrnl.exception import JrnlException +from jrnl.messages import Message +from jrnl.messages import MsgText +from jrnl.messages import MsgType + class YAMLExporter(TextExporter): """This Exporter can convert entries and journals into Markdown formatted text with YAML front matter.""" @@ -129,8 +130,4 @@ class YAMLExporter(TextExporter): @classmethod def export_journal(cls, journal): """Returns an error, as YAML export requires a directory as a target.""" - raise RuntimeError( - "{}ERROR{}: YAML export must be to individual files. Please specify a directory to export to.".format( - ERROR_COLOR, RESET_COLOR - ) - ) + raise JrnlException(Message(MsgText.YamlMustBeDirectory, MsgType.ERROR))