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 .

Depends-On: https://review.opendev.org/#/c/708069/
Change-Id: I3e0c652ce5a43d615cd2b08b5a51c0420acb0564
This commit is contained in:
manchandavishal 2020-08-28 18:59:55 +00:00
parent c8f5139ed8
commit d50a9d89d9
8 changed files with 34 additions and 34 deletions

View File

@ -86,10 +86,10 @@ class CreateForm(forms.SelfHandlingForm):
msg = _('Creating cluster "%s" successfully') % data['name']
messages.success(request, msg)
return cluster
except Exception as e:
except Exception:
redirect = reverse(INDEX_URL)
exceptions.handle(request,
_("Unable to create cluster: %s") % e,
_("Unable to create cluster."),
redirect=redirect)
@ -124,8 +124,8 @@ class ManagePoliciesForm(forms.SelfHandlingForm):
"cluster": data['cluster_id']}
messages.success(request, msg)
return attach
except Exception as e:
except Exception:
redirect = reverse(INDEX_URL)
exceptions.handle(request,
_("Unable to attach policy: %s") % e,
_("Unable to attach policy."),
redirect=redirect)

View File

@ -57,10 +57,10 @@ class IndexView(tables.DataTableView):
paginate=True,
reversed_order=reversed_order,
filters=filters)
except Exception as e:
except Exception:
self._prev = self._more = False
clusters = []
msg = _('Unable to retrieve clusters: %s') % e
msg = _('Unable to retrieve clusters.')
exceptions.handle(self.request, msg)
return clusters
@ -91,8 +91,8 @@ class DetailView(tabs.TabView):
cluster = senlin.cluster_get(self.request, cluster_id)
cluster.profile_url = reverse_lazy(self.profile_url,
args=[cluster.profile_id])
except Exception as e:
msg = _("Unable to retrieve cluster: %s") % e
except Exception:
msg = _("Unable to retrieve cluster.")
url = reverse_lazy(clusters_forms.INDEX_URL)
exceptions.handle(self.request, msg, redirect=url)
return cluster

View File

@ -85,10 +85,10 @@ class CreateForm(forms.SelfHandlingForm):
msg = _('Creating node "%s" successfully') % data['name']
messages.info(request, msg)
return node
except Exception as e:
except Exception:
redirect = reverse("horizon:cluster:nodes:index")
exceptions.handle(request,
_("Unable to create node: %s") % e,
_("Unable to create node."),
redirect=redirect)
@ -132,9 +132,9 @@ class UpdateNodeForm(forms.SelfHandlingForm):
' has been accepted for processing.') %
data['name'])
return node
except Exception as e:
except Exception:
redirect = reverse("horizon:cluster:nodes:index")
exceptions.handle(request,
_("Unable to update node: %s") % e,
_("Unable to update node."),
redirect=redirect)
return False

View File

@ -57,10 +57,10 @@ class IndexView(tables.DataTableView):
paginate=True,
reversed_order=reversed_order,
filters=filters)
except Exception as e:
except Exception:
self._prev = self._more = False
nodes = []
msg = _('Unable to retrieve nodes: %s') % e
msg = _('Unable to retrieve nodes.')
exceptions.handle(self.request, msg)
return nodes
@ -90,8 +90,8 @@ class DetailView(tabs.TabView):
# Get initial node information
node_id = self.kwargs["node_id"]
node = senlin.node_get(self.request, node_id)
except Exception as e:
msg = _("Unable to retrieve node: %s") % e
except Exception:
msg = _("Unable to retrieve node.")
url = reverse_lazy("horizon:cluster:nodes:index")
exceptions.handle(self.request, msg, redirect=url)
return node
@ -145,8 +145,8 @@ class UpdateView(forms.ModalFormView):
"role": node.role,
"metadata": metadata}
except Exception as e:
msg = _("Unable to retrieve node: %s") % e
except Exception:
msg = _("Unable to retrieve node.")
url = reverse_lazy("horizon:cluster:nodes:index")
exceptions.handle(self.request, msg, redirect=url)
return node_dict

View File

@ -90,9 +90,9 @@ class CreatePolicyForm(forms.SelfHandlingForm):
_('Your policy %s has been created.') %
args['name'])
return policy
except Exception as e:
except Exception:
redirect = reverse(INDEX_URL)
msg = _('Unable to create new policy: %s') % e
msg = _('Unable to create new policy.')
exceptions.handle(request, msg, redirect=redirect)
return False
@ -113,8 +113,8 @@ class UpdatePolicyForm(forms.SelfHandlingForm):
except ValidationError as e:
self.api_error(e.messages[0])
return False
except Exception as e:
except Exception:
redirect = reverse(INDEX_URL)
msg = _('Unable to update policy: %s') % e
msg = _('Unable to update policy.')
exceptions.handle(request, msg, redirect=redirect)
return False

View File

@ -57,10 +57,10 @@ class IndexView(tables.DataTableView):
paginate=True,
reversed_order=reversed_order,
filters=filters)
except Exception as e:
except Exception:
self._prev = self._more = False
policies = []
msg = _('Unable to retrieve policies: %s') % e
msg = _('Unable to retrieve policies.')
exceptions.handle(self.request, msg)
return policies
@ -90,8 +90,8 @@ class DetailView(tabs.TabView):
policy = senlin.policy_get(self.request, policy_id)
policy.policy_spec = yaml.safe_dump(policy.spec,
default_flow_style=False)
except Exception as e:
msg = _("Unable to retrieve policy: %s") % e
except Exception:
msg = _("Unable to retrieve policy.")
url = reverse_lazy(policies_forms.INDEX_URL)
exceptions.handle(self.request, msg, redirect=url)
return policy
@ -129,8 +129,8 @@ class UpdateView(forms.ModalFormView):
policy = senlin.policy_get(self.request, policy_id)
policy_dict = {"policy_id": policy_id,
"name": policy.name}
except Exception as e:
msg = _("Unable to retrieve policy: %s") % e
except Exception:
msg = _("Unable to retrieve policy.")
url = reverse_lazy(policies_forms.INDEX_URL)
exceptions.handle(self.request, msg, redirect=url)
return policy_dict

View File

@ -95,8 +95,8 @@ class CreateReceiverForm(forms.SelfHandlingForm):
_('Your receiver %s has been created successfully.') %
data['name'])
return receiver
except Exception as e:
except Exception:
redirect = reverse(INDEX_URL)
msg = _('Unable to create new receiver: %s') % e
msg = _('Unable to create new receiver.')
exceptions.handle(request, msg, redirect=redirect)
return False

View File

@ -55,10 +55,10 @@ class IndexView(tables.DataTableView):
paginate=True,
reversed_order=reversed_order,
filters=filters)
except Exception as e:
except Exception:
self._prev = self._more = False
receivers = []
msg = _('Unable to retrieve receivers: %s') % e
msg = _('Unable to retrieve receivers.')
exceptions.handle(self.request, msg)
return receivers
@ -87,8 +87,8 @@ class DetailView(tabs.TabView):
# Get initial receiver information
receiver_id = self.kwargs["receiver_id"]
receiver = senlin.receiver_get(self.request, receiver_id)
except Exception as e:
msg = _("Unable to retrieve receiver: %s") % e
except Exception:
msg = _("Unable to retrieve receiver.")
url = reverse_lazy("horizon:cluster:receivers:index")
exceptions.handle(self.request, msg, redirect=url)
return receiver