-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes: #15016 - Catch AssertionError from cable trace and throw ValidationError #16384
base: develop
Are you sure you want to change the base?
Changes from all commits
47f3994
7c913fe
7f48651
d4d4e50
9dc56a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class UnsupportedCablePath(Exception): | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
from django.utils.safestring import mark_safe | ||
from django.utils.translation import gettext as _ | ||
|
||
from dcim.exceptions import UnsupportedCablePath | ||
from core.signals import clear_events | ||
from utilities.error_handlers import handle_protectederror | ||
from utilities.exceptions import AbortRequest, PermissionsViolation | ||
|
@@ -319,6 +320,12 @@ def post(self, request, *args, **kwargs): | |
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is the right place to handle the exception, for two reasons. First, we want to avoid introducing any model-specific logic within a generic view. Second, this addresses only the UI workflow; it doesn't account for an API-driven change. A cleaner approach might be to catch |
||
logger.debug(e.message) | ||
form.add_error(None, e.message) | ||
clear_events.send(sender=self) | ||
|
||
else: | ||
logger.debug("Form validation failed") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review the message content, the sentence is incorrect in its current state