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