From 1eea5c3beb4ef17f7013a1068bb7cc0064d7b1ff Mon Sep 17 00:00:00 2001 From: Lei YU Date: Thu, 12 Jul 2018 15:32:37 +0800 Subject: 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 --- module/obmc/wsgi/apps/rest_dbus.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'module/obmc/wsgi/apps/rest_dbus.py') 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 -- cgit v1.2.1