From 9ca48a7940a4c23ebe43a8d04c4fe665556b7246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20D=C3=B6ll?= Date: Wed, 11 Sep 2024 11:14:36 +0000 Subject: [PATCH] fix: type asseration --- components/toasts/toasts.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/toasts/toasts.go b/components/toasts/toasts.go index 3341058..ab03db0 100644 --- a/components/toasts/toasts.go +++ b/components/toasts/toasts.go @@ -2,6 +2,7 @@ package toasts import ( "encoding/json" + "errors" "github.com/gofiber/fiber/v2" htmx "github.com/zeiss/fiber-htmx" @@ -207,17 +208,18 @@ type ToastsProps struct { // RenderToas is the handler for rendering the toasts. func RenderToasts(c *fiber.Ctx, err error) error { - te, ok := err.(Toast) + var toastErr Toast + ok := errors.As(err, &toastErr) if !ok { - te = Error("there has been an unexpected error") + toastErr = Error("there has been an unexpected error") } - if te.Level != SUCCESS { + if toastErr.Level != SUCCESS { htmx.ReSwap(c, "none") } - return te.SetHXTriggerHeader(c) + return toastErr.SetHXTriggerHeader(c) } // Notify is the container for the toast.