diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index 7c7f0ad96..5b0abcc67 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -16,6 +16,7 @@ from dcim.fields import PathField from dcim.utils import decompile_path_node, object_to_path_node from netbox.models import ChangeLoggedModel, PrimaryModel from utilities.conversion import to_meters +from utilities.exceptions import AbortRequest from utilities.fields import ColorField from utilities.querysets import RestrictedQuerySet from wireless.models import WirelessLink @@ -237,8 +238,10 @@ class Cable(PrimaryModel): for termination in self.b_terminations: if not termination.pk or termination not in b_terminations: CableTermination(cable=self, cable_end='B', termination=termination).save() - - trace_paths.send(Cable, instance=self, created=_created) + try: + trace_paths.send(Cable, instance=self, created=_created) + except UnsupportedCablePath as e: + raise AbortRequest(e) def get_status_color(self): return LinkStatusChoices.colors.get(self.status) @@ -533,7 +536,7 @@ class CablePath(models.Model): # Ensure all originating terminations are attached to the same link if len(terminations) > 1 and not all(t.link == terminations[0].link for t in terminations[1:]): - raise UnsupportedCablePath(_("All originating terminations must start must be attached to the same link")) + raise UnsupportedCablePath(_("All originating terminations must be attached to the same link")) path = [] position_stack = [] diff --git a/netbox/netbox/views/generic/object_views.py b/netbox/netbox/views/generic/object_views.py index f85a51508..243ae2547 100644 --- a/netbox/netbox/views/generic/object_views.py +++ b/netbox/netbox/views/generic/object_views.py @@ -13,7 +13,6 @@ from django.utils.html import escape from django.utils.safestring import mark_safe from django.utils.translation import gettext as _ -from dcim.exceptions import UnsupportedCablePath from extras.signals import clear_events from utilities.error_handlers import handle_protectederror from utilities.exceptions import AbortRequest, PermissionsViolation @@ -308,12 +307,6 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView): form.add_error(None, e.message) clear_events.send(sender=self) - # Catch any validation errors thrown in the model.save() or form.save() methods - except UnsupportedCablePath as e: - logger.debug(e.message) - form.add_error(None, e.message) - clear_events.send(sender=self) - else: logger.debug("Form validation failed")