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>
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 @@
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