mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-30 06:26:34 +02:00
Added Daves suggestion - generic exception handling
This commit is contained in:
parent
b7a5e0e763
commit
82c03907df
1 changed files with 10 additions and 6 deletions
|
@ -732,7 +732,7 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
ErrorCode.OBJECT_STATUS_PROHIBITS_OPERATION:
|
ErrorCode.OBJECT_STATUS_PROHIBITS_OPERATION:
|
||||||
f"Cannot delete Domain when in status {obj.status}",
|
f"Cannot delete Domain when in status {obj.status}",
|
||||||
ErrorCode.OBJECT_ASSOCIATION_PROHIBITS_OPERATION:
|
ErrorCode.OBJECT_ASSOCIATION_PROHIBITS_OPERATION:
|
||||||
"This subdomain is being used as a hostname on another domain"
|
"This subdomain is being used as a hostname on another domain",
|
||||||
}
|
}
|
||||||
|
|
||||||
message = "Cannot connect to the registry"
|
message = "Cannot connect to the registry"
|
||||||
|
@ -740,9 +740,7 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
# If nothing is found, will default to returned err
|
# If nothing is found, will default to returned err
|
||||||
message = error_messages.get(err.code, err)
|
message = error_messages.get(err.code, err)
|
||||||
self.message_user(
|
self.message_user(
|
||||||
request,
|
request, f"Error deleting this Domain: {message}", messages.ERROR
|
||||||
f"Error deleting this Domain: {message}",
|
|
||||||
messages.ERROR
|
|
||||||
)
|
)
|
||||||
except TransitionNotAllowed:
|
except TransitionNotAllowed:
|
||||||
if obj.state == Domain.State.DELETED:
|
if obj.state == Domain.State.DELETED:
|
||||||
|
@ -755,15 +753,21 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
self.message_user(
|
self.message_user(
|
||||||
request,
|
request,
|
||||||
"Error deleting this Domain: "
|
"Error deleting this Domain: "
|
||||||
f"Can't switch from state '{obj.state}' to 'deleted'"
|
f"Can't switch from state '{obj.state}' to 'deleted'",
|
||||||
,
|
|
||||||
messages.ERROR,
|
messages.ERROR,
|
||||||
)
|
)
|
||||||
|
except Exception:
|
||||||
|
self.message_user(
|
||||||
|
request,
|
||||||
|
"Could not delete: An unspecified error occured",
|
||||||
|
messages.ERROR,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.message_user(
|
self.message_user(
|
||||||
request,
|
request,
|
||||||
("Domain %s has been deleted. Thanks!") % obj.name,
|
("Domain %s has been deleted. Thanks!") % obj.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
return HttpResponseRedirect(".")
|
return HttpResponseRedirect(".")
|
||||||
|
|
||||||
def do_get_status(self, request, obj):
|
def do_get_status(self, request, obj):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue