From 44b6ba9a4ae21c7a0a946e2f6e29e5079b6ed249 Mon Sep 17 00:00:00 2001 From: Enzo Candotti Date: Mon, 27 Sep 2021 18:57:32 -0300 Subject: [PATCH] Adding more info on strategy apply error message Error messages are not clear enough when something goes wrong at the moment of creating the strategy. For example, when creating a strategy for an nonexistent subcloud or subcloud group, the same error message was displayed: "Error: Strategy creation failed." This change add more information about the error. For instance: Error: Strategy creation failed: "Invalid group_id" Closes-Bug: 1944766 Signed-off-by: Enzo Candotti Change-Id: Ie6d368537fa826e1995ffc961bba34e8b08f7c3c --- .../dashboards/dc_admin/dc_software_management/forms.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/forms.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/forms.py index cc9bd141..dc6fa75a 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/forms.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/dashboards/dc_admin/dc_software_management/forms.py @@ -39,7 +39,8 @@ class ApplyCloudStrategyForm(forms.SelfHandlingForm): except Exception as ex: LOG.exception(ex) redirect = reverse(self.failure_url) - exceptions.handle(request, "Strategy apply failed", + msg = _('Strategy apply failed: "%s".') % str(ex) + exceptions.handle(request, msg, redirect=redirect) return True @@ -189,9 +190,10 @@ class CreateCloudStrategyForm(forms.SelfHandlingForm): response = api.dc_manager.strategy_create(request, data) if not response: messages.error(request, "Strategy creation failed") - except Exception: + except Exception as ex: redirect = reverse(self.failure_url) - exceptions.handle(request, "Strategy creation failed", + msg = _('Strategy creation failed: "%s".') % str(ex) + exceptions.handle(request, msg, redirect=redirect) return True