summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoonas Kylmälä <joonas.kylmala@iki.fi>2017-07-12 11:23:04 +0000
committerScott Moser <smoser@brickies.net>2017-07-17 09:38:06 -0400
commitb6c478e07008819ea1a69a666f3a97c89f457e19 (patch)
tree8fff72cda192b443944e090208db82cd311003b7
parent7b13279109d9eb3d1b102bb5ae8900c3d8423537 (diff)
downloadvyos-cloud-init-b6c478e07008819ea1a69a666f3a97c89f457e19.tar.gz
vyos-cloud-init-b6c478e07008819ea1a69a666f3a97c89f457e19.zip
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
-rwxr-xr-xtools/mock-meta.py4
1 files 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:], {