diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-07-29 13:06:32 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-07-29 13:06:32 -0400 |
commit | e99f956d787fc9185e70fb5d31ede6fee0139226 (patch) | |
tree | c9783de2883a0bef3cda0ff379db268a125b24a6 | |
parent | 67428ad5a66ee57d1212e5af74cb9e9ed81d2c7b (diff) | |
download | vyos-cloud-init-e99f956d787fc9185e70fb5d31ede6fee0139226.tar.gz vyos-cloud-init-e99f956d787fc9185e70fb5d31ede6fee0139226.zip |
cc_power_state_change: improve TypeError messages
Include the value that was found to be invalid in the error message.
-rw-r--r-- | cloudinit/config/cc_power_state_change.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cloudinit/config/cc_power_state_change.py b/cloudinit/config/cc_power_state_change.py index 8f99e887..638daef8 100644 --- a/cloudinit/config/cc_power_state_change.py +++ b/cloudinit/config/cc_power_state_change.py @@ -89,8 +89,9 @@ def load_power_state(cfg): mode = pstate.get("mode") if mode not in opt_map: - raise TypeError("power_state[mode] required, must be one of: %s." % - ','.join(opt_map.keys())) + raise TypeError( + "power_state[mode] required, must be one of: %s. found: '%s'." % + (','.join(opt_map.keys()), mode)) delay = pstate.get("delay", "now") # convert integer 30 or string '30' to '+30' @@ -100,7 +101,9 @@ def load_power_state(cfg): pass if delay != "now" and not re.match(r"\+[0-9]+", delay): - raise TypeError("power_state[delay] must be 'now' or '+m' (minutes).") + raise TypeError( + "power_state[delay] must be 'now' or '+m' (minutes)." + " found '%s'." % delay) args = ["shutdown", opt_map[mode], delay] if pstate.get("message"): |