fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

11K
active users

Anže :python:

One thing that I'm missing with HTMX and Django is proper error handling.

By default HTMX swallows any response that is not a 2xx, which might leave your users hanging on an endless loading state.

Does anyone have a good solution for this that can be reused between projects?

As a stopgap solution I solved this by returning a 200 response with an error content, but I am curious how others deal with errors and HTMX.

@dunsap oh I didn't know about this extension. Looks cool, thanks for sharing!

@anze3db I’m not sure there’s a better way than what you’re doing right now that doesn’t involve listening for the responseError event and writing client-side JS. They could add hx-error-swap / hx-error-target, for example, to implement this. Might be worth suggesting. (1/2)

@aral @anze3db That’s what I ended up doing which, while not ideal, was OK because I needed some basic interactivity as well.

@benjaoming For this particular example I think a local error text is more appropriate than a global toast, but I will also need toasts for other things so this is useful, thanks again!