mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-30 22:46:12 +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
|
@ -7,7 +7,11 @@ import yaml
|
|||
import xdg.BaseDirectory
|
||||
|
||||
from . import __version__
|
||||
from .exception import JrnlError
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
from jrnl.messages import MsgText
|
||||
from jrnl.messages import MsgType
|
||||
|
||||
from .color import ERROR_COLOR
|
||||
from .color import RESET_COLOR
|
||||
from .output import list_journals
|
||||
|
@ -68,12 +72,18 @@ def get_config_path():
|
|||
try:
|
||||
config_directory_path = xdg.BaseDirectory.save_config_path(XDG_RESOURCE)
|
||||
except FileExistsError:
|
||||
raise JrnlError(
|
||||
"ConfigDirectoryIsFile",
|
||||
config_directory_path=os.path.join(
|
||||
xdg.BaseDirectory.xdg_config_home, XDG_RESOURCE
|
||||
raise JrnlException(
|
||||
Message(
|
||||
MsgText.ConfigDirectoryIsFile,
|
||||
MsgType.ERROR,
|
||||
{
|
||||
"config_directory_path": os.path.join(
|
||||
xdg.BaseDirectory.xdg_config_home, XDG_RESOURCE
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
return os.path.join(
|
||||
config_directory_path or os.path.expanduser("~"), DEFAULT_CONFIG_NAME
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue