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: I1ddea97cdcaf4142d9dabcf4a629e805a9c1e152
This commit is contained in:
parent
2bfbee4bb9
commit
b4991fcf25
@ -240,10 +240,10 @@ class EditAlarmForm(forms.SelfHandlingForm):
|
||||
def set_notification_choices(self, request):
|
||||
try:
|
||||
notifications = api.monitor.notification_list(request)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
notifications = []
|
||||
exceptions.handle(request,
|
||||
_('Unable to retrieve notifications: %s') % e)
|
||||
_('Unable to retrieve notifications.'))
|
||||
notification_choices = [
|
||||
(notification['id'], notification) for notification in notifications]
|
||||
|
||||
@ -267,7 +267,8 @@ class EditAlarmForm(forms.SelfHandlingForm):
|
||||
)
|
||||
messages.success(request,
|
||||
_('Alarm definition has been updated.'))
|
||||
except Exception as e:
|
||||
exceptions.handle(request, _('%s') % e)
|
||||
except Exception:
|
||||
exceptions.handle(request,
|
||||
_('Unable to update alarm definition.'))
|
||||
return False
|
||||
return True
|
||||
|
@ -62,9 +62,9 @@ class SetAlarmNotificationsAction(workflows.Action):
|
||||
try:
|
||||
notifications = ad_forms._get_notifications(request)
|
||||
self.fields['notifications'].choices = notifications
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
exceptions.handle(request,
|
||||
_('Unable to retrieve notifications: %s') % e)
|
||||
_('Unable to retrieve notifications.'))
|
||||
|
||||
|
||||
_SEVERITY_CHOICES = [("LOW", _("Low")),
|
||||
@ -221,8 +221,10 @@ class AlarmDefinitionWorkflow(workflows.Workflow):
|
||||
ok_actions=context['ok_actions'],
|
||||
undetermined_actions=context['undetermined_actions'],
|
||||
)
|
||||
except Exception as e:
|
||||
exceptions.handle(request, e, escalate=True)
|
||||
except Exception:
|
||||
exceptions.handle(request,
|
||||
_('Unable to create alarm definition.'),
|
||||
escalate=True)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -213,10 +213,10 @@ class BaseAlarmForm(forms.SelfHandlingForm):
|
||||
def set_notification_choices(self, request):
|
||||
try:
|
||||
notifications = api.monitor.notification_list(request)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
notifications = []
|
||||
exceptions.handle(request,
|
||||
_('Unable to retrieve notifications: %s') % e)
|
||||
_('Unable to retrieve notifications.'))
|
||||
notification_choices = [(notification['id'], notification['name'])
|
||||
for notification in notifications]
|
||||
if notification_choices:
|
||||
@ -264,8 +264,8 @@ class CreateAlarmForm(BaseAlarmForm):
|
||||
)
|
||||
messages.success(request,
|
||||
_('Alarm has been created successfully.'))
|
||||
except Exception as e:
|
||||
exceptions.handle(request, _('Unable to create the alarm: %s') % e.message)
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Unable to create the alarm.'))
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -298,7 +298,7 @@ class EditAlarmForm(BaseAlarmForm):
|
||||
)
|
||||
messages.success(request,
|
||||
_('Alarm has been edited successfully.'))
|
||||
except Exception as e:
|
||||
exceptions.handle(request, _('Unable to edit the alarm: %s') % e)
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Unable to edit the alarm.'))
|
||||
return False
|
||||
return True
|
||||
|
@ -118,10 +118,9 @@ class CreateMethodForm(BaseNotificationMethodForm):
|
||||
messages.success(request,
|
||||
_('Notification method has been created '
|
||||
'successfully.'))
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
exceptions.handle(request,
|
||||
_('Unable to create the notification '
|
||||
'method: %s') % e)
|
||||
_('Unable to create the notification method.'))
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -154,8 +153,8 @@ class EditMethodForm(BaseNotificationMethodForm):
|
||||
)
|
||||
messages.success(request,
|
||||
_('Notification has been edited successfully.'))
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
exceptions.handle(request,
|
||||
_('Unable to edit the notification: %s') % e)
|
||||
_('Unable to edit the notification.'))
|
||||
return False
|
||||
return True
|
||||
|
@ -49,11 +49,9 @@ class DeleteNotification(tables.DeleteAction):
|
||||
def delete(self, request, obj_id):
|
||||
try:
|
||||
api.monitor.notification_delete(request, obj_id)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
exceptions.handle(
|
||||
request,
|
||||
_('Unable to delete notification: %s') %
|
||||
e)
|
||||
request, _('Unable to delete notification.'))
|
||||
|
||||
|
||||
class CreateNotification(tables.LinkAction):
|
||||
|
Loading…
Reference in New Issue
Block a user