Improve error message for non-exist nvtake targets

`nvtake foo` was giving the following error:

```
Traceback (most recent call last):
  File "/usr/bin/nvtake", line 11, in <module>
    load_entry_point('nvchecker==0.5', 'console_scripts', 'nvtake')()
  File "/usr/lib/python3.6/site-packages/nvchecker/tools.py", line 34, in take
    oldvers[name] = newvers[name]
KeyError: 'foo'
```

This is unclear and too verbose. With the change it is now:

```
[C 08-05 02:51:46.767 tools:38] foo doesn't exist in 'newver' set.
```
This commit is contained in:
Felix Yan 2017-08-05 02:51:14 +08:00
parent 933df7da4c
commit 39d1895b2b
No known key found for this signature in database
GPG Key ID: 786C63F330D7CB92
1 changed files with 7 additions and 1 deletions

View File

@ -31,7 +31,13 @@ def take():
newvers = core.read_verfile(s.newver)
for name in args.names:
oldvers[name] = newvers[name]
try:
oldvers[name] = newvers[name]
except KeyError:
logger.fatal(
"%s doesn't exist in 'newver' set.", name
)
sys.exit(2)
try:
os.rename(s.oldver, s.oldver + '~')