htmx icon indicating copy to clipboard operation
htmx copied to clipboard

add extension swap-errors

Open jgirardet opened this issue 4 years ago • 3 comments

the swap-errors extension allows swapping response when HTTP Error code is returned. It's nice way to deal with errors server-side in It works adding the header HX-SWAP-ERRORS in the response.

jgirardet avatar Oct 20 '21 07:10 jgirardet

@jgirardet do you think that this extension has been obviated by the new support for configuring swap behavior in the htmx:beforeSwap event?

1cg avatar Nov 12 '21 22:11 1cg

No I don't. This extension allows you to write less javascript where htmx:beforeSwap forces to write more JavaScript. Since many errors are handled server side, I think it's better for htmx to support the result (with a non 200 status code) out of the box.

jgirardet avatar Nov 15 '21 16:11 jgirardet

I agree, I think this would be extremely useful. It's sad to see that this never got merged.

vrecan avatar Jul 06 '22 15:07 vrecan

This extension allows you to write less javascript where htmx:beforeSwap forces to write more JavaScript. Since many errors are handled server side, I think it's better for htmx to support the result (with a non 200 status code) out of the box.

I agree with this, though coming up with a conceptual framework that allows configuration via attributes (instead of JS) is difficult!

We're working with this concept in #1620, so I'm going to close this PR in favor of that.

alexpetros avatar Jul 30 '23 17:07 alexpetros