From 0af8c03fafc24284754e1486d17b37cdd5770def Mon Sep 17 00:00:00 2001 From: manchandavishal Date: Wed, 26 Aug 2020 12:22:42 +0000 Subject: [PATCH] Cleanup for Refactor-error-messages This patch is a clean-up patch for refactor-error-messages bp which remove the exception message from base message otherwise the same exception message display twice like this https://ibb.co/XyFWMdz . Change-Id: Ib56b35b164057b821b5e9755202b87c9e1ea5572 --- mistraldashboard/actions/forms.py | 8 ++++---- mistraldashboard/actions/views.py | 4 ++-- mistraldashboard/executions/forms.py | 4 ++-- mistraldashboard/executions/tables.py | 7 ++----- mistraldashboard/executions/views.py | 14 +++++--------- mistraldashboard/tasks/tables.py | 7 ++----- mistraldashboard/workbooks/forms.py | 8 ++++---- mistraldashboard/workflows/forms.py | 12 ++++++------ 8 files changed, 27 insertions(+), 37 deletions(-) diff --git a/mistraldashboard/actions/forms.py b/mistraldashboard/actions/forms.py index 395ca60..7d69247 100644 --- a/mistraldashboard/actions/forms.py +++ b/mistraldashboard/actions/forms.py @@ -130,8 +130,8 @@ class CreateForm(forms.SelfHandlingForm): messages.success(request, msg) return True - except Exception as e: - msg = _('Failed to create action: %s') % e + except Exception: + msg = _('Failed to create action.') redirect = reverse('horizon:mistral:actions:index') exceptions.handle(request, msg, redirect=redirect) @@ -188,7 +188,7 @@ class UpdateForm(forms.SelfHandlingForm): messages.success(request, msg) return True - except Exception as e: - msg = _('Failed to update action: %s') % e + except Exception: + msg = _('Failed to update action.') redirect = reverse('horizon:mistral:actions:index') exceptions.handle(request, msg, redirect=redirect) diff --git a/mistraldashboard/actions/views.py b/mistraldashboard/actions/views.py index 92b97fd..c59891b 100644 --- a/mistraldashboard/actions/views.py +++ b/mistraldashboard/actions/views.py @@ -97,10 +97,10 @@ class IndexView(tables.DataTableView): reverse=False ) - except Exception as e: + except Exception: self._prev = False self._more = False - msg = _('Unable to retrieve actions list: %s') % str(e) + msg = _('Unable to retrieve actions list.') exceptions.handle(self.request, msg) return actions diff --git a/mistraldashboard/executions/forms.py b/mistraldashboard/executions/forms.py index 144e260..93fd851 100644 --- a/mistraldashboard/executions/forms.py +++ b/mistraldashboard/executions/forms.py @@ -39,7 +39,7 @@ class UpdateDescriptionForm(forms.SelfHandlingForm): return True - except Exception as e: - msg = _('Failed to update execution description: %s') % e + except Exception: + msg = _('Failed to update execution description.') redirect = reverse('horizon:mistral:executions:index') exceptions.handle(request, msg, redirect=redirect) diff --git a/mistraldashboard/executions/tables.py b/mistraldashboard/executions/tables.py index 6646457..de61d21 100644 --- a/mistraldashboard/executions/tables.py +++ b/mistraldashboard/executions/tables.py @@ -145,12 +145,9 @@ class UpdateRow(tables.Row): def get_data(self, request, id): try: instance = api.execution_get(request, id) - except Exception as e: - msg = _("Unable to get execution by ID %(id)s: %(e)s.") % { - 'id': id, 'e': str(e) - } + except Exception: + msg = _('Unable to get execution by ID "%s".') % id exceptions.handle(request, msg) - return instance diff --git a/mistraldashboard/executions/views.py b/mistraldashboard/executions/views.py index 0771df7..f0017a0 100644 --- a/mistraldashboard/executions/views.py +++ b/mistraldashboard/executions/views.py @@ -113,12 +113,11 @@ class IndexView(tables.DataTableView): reverse=True ) - except Exception as e: + except Exception: self._prev = False self._more = False - msg = _('Unable to retrieve executions list: %s') % e + msg = _('Unable to retrieve executions list.') exceptions.handle(self.request, msg) - return executions @@ -168,15 +167,12 @@ class TasksView(tables.DataTableView): reverse=True ) - except Exception as e: + except Exception: self._prev = False self._more = False - msg = ( - _('Unable to retrieve executions list of ' - 'the requested task: %s') % e - ) + msg = _('Unable to retrieve executions list of ' + 'the requested task.') exceptions.handle(self.request, msg) - return executions diff --git a/mistraldashboard/tasks/tables.py b/mistraldashboard/tasks/tables.py index 3fe3df4..976980b 100644 --- a/mistraldashboard/tasks/tables.py +++ b/mistraldashboard/tasks/tables.py @@ -33,12 +33,9 @@ class UpdateRow(tables.Row): def get_data(self, request, id): try: instance = api.task_get(request, id) - except Exception as e: - msg = _("Unable to get task by ID %(id)s: %(e)s.") % { - 'id': id, 'e': str(e) - } + except Exception: + msg = _('Unable to get task by ID "%s".') % id exceptions.handle(request, msg) - return instance diff --git a/mistraldashboard/workbooks/forms.py b/mistraldashboard/workbooks/forms.py index d3cff93..c86e137 100644 --- a/mistraldashboard/workbooks/forms.py +++ b/mistraldashboard/workbooks/forms.py @@ -106,8 +106,8 @@ class CreateForm(forms.SelfHandlingForm): messages.success(request, msg) return True - except Exception as e: - msg = _('Failed to create workbook: %s') % e + except Exception: + msg = _('Failed to create workbook.') redirect = reverse('horizon:mistral:workbooks:index') exceptions.handle(request, msg, redirect=redirect) @@ -121,7 +121,7 @@ class UpdateForm(CreateForm): messages.success(request, msg) return True - except Exception as e: - msg = _('Failed to update workbook: %s') % e + except Exception: + msg = _('Failed to update workbook.') redirect = reverse('horizon:mistral:workbooks:index') exceptions.handle(request, msg, redirect=redirect) diff --git a/mistraldashboard/workflows/forms.py b/mistraldashboard/workflows/forms.py index ba2608f..06e9863 100644 --- a/mistraldashboard/workflows/forms.py +++ b/mistraldashboard/workflows/forms.py @@ -69,8 +69,8 @@ class ExecuteForm(forms.SelfHandlingForm): messages.success(request, msg) return True - except Exception as e: - msg = _('Failed to execute workflow "%s".') % e + except Exception: + msg = _('Failed to execute workflow.') redirect = reverse('horizon:mistral:workflows:index') exceptions.handle(request, msg, redirect=redirect) @@ -159,8 +159,8 @@ class CreateForm(forms.SelfHandlingForm): messages.success(request, msg) return True - except Exception as e: - msg = _('Failed to create workflow: %s') % e + except Exception: + msg = _('Failed to create workflow.') redirect = reverse('horizon:mistral:workflows:index') exceptions.handle(request, msg, redirect=redirect) @@ -174,7 +174,7 @@ class UpdateForm(CreateForm): messages.success(request, msg) return True - except Exception as e: - msg = _('Failed to update workflow: %s') % e + except Exception: + msg = _('Failed to update workflow.') redirect = reverse('horizon:mistral:workflows:index') exceptions.handle(request, msg, redirect=redirect)