mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-07 00:36:13 +02:00
Reformat messages and add new centralized exception handling (#1417)
* 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:
parent
d6ff04cf17
commit
5273f8769d
11 changed files with 204 additions and 96 deletions
|
@ -13,7 +13,10 @@ avoid any possible overhead for these standalone commands.
|
|||
"""
|
||||
import platform
|
||||
import sys
|
||||
from .exception import JrnlError
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.messages import MsgType
|
||||
|
||||
|
||||
def preconfig_diagnostic(_):
|
||||
|
@ -70,10 +73,15 @@ def postconfig_encrypt(args, config, original_config, **kwargs):
|
|||
journal = open_journal(args.journal_name, config)
|
||||
|
||||
if hasattr(journal, "can_be_encrypted") and not journal.can_be_encrypted:
|
||||
raise JrnlError(
|
||||
"CannotEncryptJournalType",
|
||||
journal_name=args.journal_name,
|
||||
journal_type=journal.__class__.__name__,
|
||||
raise JrnlException(
|
||||
Message(
|
||||
MsgText.CannotEncryptJournalType,
|
||||
MsgType.ERROR,
|
||||
{
|
||||
"journal_name": args.journal_name,
|
||||
"journal_type": journal.__class__.__name__,
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
journal.config["encrypt"] = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue