jrnl/jrnl/exception.py
Jonathan Wren 5273f8769d
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>
2022-03-12 12:43:26 -08:00

25 lines
595 B
Python

# Copyright (C) 2012-2021 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html
from jrnl.messages import Message
from jrnl.output import print_msg
class UserAbort(Exception):
pass
class UpgradeValidationException(Exception):
"""Raised when the contents of an upgraded journal do not match the old journal"""
pass
class JrnlException(Exception):
"""Common exceptions raised by jrnl."""
def __init__(self, *messages: Message):
self.messages = messages
def print(self) -> None:
for msg in self.messages:
print_msg(msg)