From 45347da3117cbeab9e3de993ad24c5f4afcba13d Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 22 Dec 2019 21:47:25 +0000 Subject: [PATCH] Improve error messages --- evering/__main__.py | 3 ++- evering/config.py | 4 ++-- evering/process.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/evering/__main__.py b/evering/__main__.py index 2ee983e..0067828 100644 --- a/evering/__main__.py +++ b/evering/__main__.py @@ -79,7 +79,8 @@ def run(args: Any) -> None: raise CatastrophicError("Aborted") for path in known_files.find_forgotten_files(): - logger.info(f"The file {style_path(path)} is no longer known") + logger.info(style_warning("The file ") + style_path(path) + + style_warning(" is no longer known")) known_files.save_final() diff --git a/evering/config.py b/evering/config.py index 0137e94..fa233ac 100644 --- a/evering/config.py +++ b/evering/config.py @@ -6,10 +6,10 @@ The result of loading a config file are the "local" variables, including the modules loaded via "import". """ +import logging from dataclasses import dataclass from pathlib import Path from typing import Any, Dict, List, Optional, Tuple, Union -import logging from .colors import * from .util import * @@ -183,7 +183,7 @@ class Config: conf = copy break except ConfigurationException as e: - logger.debug(f"Tried default config file at {style_path(path)} and it didn't work") + logger.debug(f"Tried default config file at {style_path(path)} and it didn't work: {e}") else: raise ConfigurationException(style_error( "No valid config file found in any of the default locations")) diff --git a/evering/process.py b/evering/process.py index 6ae29d7..348c452 100644 --- a/evering/process.py +++ b/evering/process.py @@ -190,14 +190,14 @@ class Processor: logger.warning(style_warning("The target is a directory")) return False - target_hash = self._obtain_hash(target) - if target_hash is None: - return prompt_yes_no("Overwriting a file that could not be hashed, continue?", False) - if self.known_files.was_recently_modified(target): logger.warning(style_warning("This target was already overwritten earlier")) return False + target_hash = self._obtain_hash(target) + if target_hash is None: + return prompt_yes_no("Overwriting a file that could not be hashed, continue?", False) + known_target_hash = self.known_files.get_hash(target) if known_target_hash is None: return prompt_yes_no("Overwriting an unknown file, continue?", False)