Improve error messages

This commit is contained in:
Joscha 2019-12-22 21:47:25 +00:00
parent 381e50dec6
commit 45347da311
3 changed files with 8 additions and 7 deletions

View file

@ -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()

View file

@ -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"))

View file

@ -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)