From b6c478e07008819ea1a69a666f3a97c89f457e19 Mon Sep 17 00:00:00 2001 From: Joonas Kylmälä Date: Wed, 12 Jul 2017 11:23:04 +0000 Subject: tools: Fix exception handling. We should be expecting IndexError instead of KeyError because we are using a list (key_ids) and not a dictionary. Also, thanks to Emmanuel Kasper for pointing out the wrong response code. LP: #1701527 --- tools/mock-meta.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/mock-meta.py b/tools/mock-meta.py index f185dbf2..a5d14ab7 100755 --- a/tools/mock-meta.py +++ b/tools/mock-meta.py @@ -262,8 +262,8 @@ class MetaDataHandler(object): except ValueError: raise WebException(hclient.BAD_REQUEST, "%s: not an integer" % mybe_key) - except KeyError: - raise WebException(hclient.BAD_REQUEST, + except IndexError: + raise WebException(hclient.NOT_FOUND, "Unknown key id %r" % mybe_key) # Extract the possible sub-params result = traverse(nparams[1:], { -- cgit v1.2.3