Fix catchall exceptions.

Using ValueError for everything caused underlying issues to be
hidden. Now there are explicit classes for each error condition.
This commit is contained in:
Manuel Barkhau 2019-03-28 23:37:58 +01:00
parent 4c03738938
commit 69fadc2de9
5 changed files with 34 additions and 19 deletions

View file

@ -77,8 +77,8 @@ def test_error_bad_path():
(project.dir / "setup.py").unlink()
try:
list(rewrite._iter_file_paths(cfg.file_patterns))
assert False, "expected ValueError"
except ValueError as ex:
assert False, "expected FileNotFoundError"
except FileNotFoundError as ex:
assert "setup.py" in str(ex)
@ -93,6 +93,5 @@ def test_error_bad_pattern():
try:
list(rewrite.diff("v201809.1234", patterns))
assert False, "expected ValueError"
except ValueError as ex:
except rewrite.NoPatternMatch as ex:
assert "setup.py" in str(ex)