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 <enzo.candotti@windriver.com>
Change-Id: Ie6d368537fa826e1995ffc961bba34e8b08f7c3c
This commit is contained in:
Enzo Candotti 2021-09-27 18:57:32 -03:00
parent 46a76ed445
commit 44b6ba9a4a
1 changed files with 5 additions and 3 deletions

View File

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