Update and modularize exception handling

cc #1024 #1141

- Stack traces are no longer shown to users unless the --debug flag is
  being used
- Errors, warnings, and other messages contain color as needed
- Converted error messages to Enum
- Adds print_msg function to centralize output (this should replace all
  other output in other modules)

Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
Jonathan Wren 2022-02-05 16:05:43 -08:00
parent 49930e16f7
commit 09c04aa5de
9 changed files with 135 additions and 63 deletions

View file

@ -1,6 +1,7 @@
import pytest
from jrnl.exception import JrnlError
from jrnl.exception import JrnlException
from jrnl.exception import JrnlExceptionMessage
from jrnl.plugins.fancy_exporter import check_provided_linewrap_viability
@ -23,6 +24,8 @@ class TestFancy:
total_linewrap = 12
with pytest.raises(JrnlError) as e:
with pytest.raises(JrnlException) as e:
check_provided_linewrap_viability(total_linewrap, [content], journal)
assert e.value.error_type == "LineWrapTooSmallForDateFormat"
assert (
e.value.exception_msg == JrnlExceptionMessage.LineWrapTooSmallForDateFormat
)