Skip to content

Commit

Permalink
fix: type asseration
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Sep 11, 2024
1 parent 512fa93 commit 9ca48a7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions components/toasts/toasts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package toasts

import (
"encoding/json"
"errors"

"github.com/gofiber/fiber/v2"
htmx "github.com/zeiss/fiber-htmx"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9ca48a7

Please sign in to comment.