diff options
author | Lei YU <mine260309@gmail.com> | 2018-07-12 15:32:37 +0800 |
---|---|---|
committer | Lei YU <mine260309@gmail.com> | 2018-07-12 15:32:37 +0800 |
commit | 1eea5c3beb4ef17f7013a1068bb7cc0064d7b1ff (patch) | |
tree | 85192dc73da6382ed0dab5ba81add8bdfe5cd7e0 /module/obmc | |
parent | 0cf702c3948487089723d539efc59275b958bf34 (diff) | |
download | phosphor-rest-server-1eea5c3beb4ef17f7013a1068bb7cc0064d7b1ff.tar.gz phosphor-rest-server-1eea5c3beb4ef17f7013a1068bb7cc0064d7b1ff.zip |
Fix error message in do_put()
do_put() always reports "Failed to convert to type" when it gets
exception during retry.
This is not wrong because it may gets the real error from Dbus instead
of convert_type().
Fix it by using try-except for both convert_type() and self.do_put() to
correctly report the error.
Resolves: openbmc/openbmc#3301
Tested: Setting host time when time config does not allow this, and
verify the correct error is reported.
Change-Id: Ic46cedb7ea20d91d94b45568af9acd55af9caf56
Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'module/obmc')
-rw-r--r-- | module/obmc/wsgi/apps/rest_dbus.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py index f761df9..d89cb68 100644 --- a/module/obmc/wsgi/apps/rest_dbus.py +++ b/module/obmc/wsgi/apps/rest_dbus.py @@ -507,11 +507,15 @@ class PropertyHandler(RouteHandler): converted_value = None try: converted_value = convert_type(expected_type, value) - self.do_put(path, prop, converted_value, False) - return except Exception as ex: abort(403, "Failed to convert %s to type %s" % (value, expected_type)) + try: + self.do_put(path, prop, converted_value, False) + return + except Exception as ex: + abort(403, str(ex)) + abort(403, str(e)) raise |