mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-12 01:18:31 +02:00
* Moving configuration values and methods from install.py to config.py -- everything is broken right now * Using context to store config path - still lots broken * Use mocks and context.config_path to store test configs - many tests still broken though * Update changelog [ci skip] * Fix jrnl --ls crash * Fix crash when no editor configured * Attempt to patch config path with test data - doesn't appear to be working * Properly use patched config path and add config given to scenario that wasn't using it * Fix copypasta * Fix editor test that needed patched config and trapping for system exit * Add exception and handling for when configuration directory is actually a file * Remove extraneous comment * Use more generic JrnlError with messaging switchboard * Format code a bit nicer * Remove unnecessary given in diagnostic test * Ensure full error message is output * Remove unnecessary whitespace characters
38 lines
983 B
Python
38 lines
983 B
Python
# Copyright (C) 2012-2021 jrnl contributors
|
|
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
|
import textwrap
|
|
|
|
|
|
class UserAbort(Exception):
|
|
pass
|
|
|
|
|
|
class UpgradeValidationException(Exception):
|
|
"""Raised when the contents of an upgraded journal do not match the old journal"""
|
|
|
|
pass
|
|
|
|
|
|
class JrnlError(Exception):
|
|
"""Common exceptions raised by jrnl. """
|
|
|
|
def __init__(self, error_type, **kwargs):
|
|
self.error_type = error_type
|
|
self.message = self._get_error_message(**kwargs)
|
|
|
|
def _get_error_message(self, **kwargs):
|
|
error_messages = {
|
|
"ConfigDirectoryIsFile": textwrap.dedent(
|
|
"""
|
|
The path to your jrnl configuration directory is a file, not a directory:
|
|
|
|
{config_directory_path}
|
|
|
|
Removing this file will allow jrnl to save its configuration.
|
|
"""
|
|
)
|
|
}
|
|
|
|
return error_messages[self.error_type].format(**kwargs)
|
|
|
|
pass
|