From 7564dae48260059d1d0cc6774acd9edd59c0688a Mon Sep 17 00:00:00 2001 From: podliashanyk <60876078+podliashanyk@users.noreply.github.com> Date: Fri, 24 Jan 2025 11:10:11 +0100 Subject: [PATCH] More precise error msg on destination delete (#1148) * Show original exception message on destination delete --- changelog.d/1147.fixed.md | 1 + src/argus/htmx/destination/views.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog.d/1147.fixed.md diff --git a/changelog.d/1147.fixed.md b/changelog.d/1147.fixed.md new file mode 100644 index 000000000..e489a6978 --- /dev/null +++ b/changelog.d/1147.fixed.md @@ -0,0 +1 @@ +Show relevant error message on destination delete by passing the original exception message to the UI. diff --git a/src/argus/htmx/destination/views.py b/src/argus/htmx/destination/views.py index fdd4cd489..df3c102c4 100644 --- a/src/argus/htmx/destination/views.py +++ b/src/argus/htmx/destination/views.py @@ -34,8 +34,8 @@ def delete_htmx(request, pk: int) -> HttpResponse: try: medium = api_safely_get_medium_object(destination.media.slug) medium.raise_if_not_deletable(destination) - except NotificationMedium.NotDeletableError: - error_msg = "That destination cannot be deleted." + except NotificationMedium.NotDeletableError as e: + error_msg = " ".join(e.args) else: destination.delete()