From 013a19248507ce9c743800897a0a2dea6089a5c5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 18 Mar 2021 11:16:13 +0100 Subject: [PATCH] web: Improve error handling in deleteform Signed-off-by: Jens Langhammer --- web/src/elements/forms/DeleteForm.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/src/elements/forms/DeleteForm.ts b/web/src/elements/forms/DeleteForm.ts index 9addbd92d..8c89f7d9a 100644 --- a/web/src/elements/forms/DeleteForm.ts +++ b/web/src/elements/forms/DeleteForm.ts @@ -1,6 +1,7 @@ import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; import { ModalButton } from "../buttons/ModalButton"; +import { showMessage } from "../messages/MessageContainer"; @customElement("ak-forms-delete") export class DeleteForm extends ModalButton { @@ -23,7 +24,12 @@ export class DeleteForm extends ModalButton { composed: true, }) ); - }); + }).catch((e) => { + showMessage({ + message: gettext(`Failed to delete ${this.objectLabel}: ${e.toString()}`), + level_tag: "error", + }) + }) } renderModalInner(): TemplateResult {