handle missing items in cache show

Change-Id: I3ad4f4b7e7cbc4017d57beccb297e4ae2a5d15b2
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-05-05 20:02:49 -04:00
parent e1ae7cb94a
commit 83cd9bbc36

View File

@ -59,5 +59,9 @@ class CacheShow(command.Command):
def take_action(self, parsed_args):
cache = self.app._load_cache_file(preload=False)
data = cache[(parsed_args.type, parsed_args.id)]
pprint.pprint(data)
try:
data = cache[(parsed_args.type, parsed_args.id)]
pprint.pprint(data)
except KeyError:
msg = 'no {} with id {}'.format(parsed_args.type, parsed_args.id)
raise RuntimeError(msg)