Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question - How to handle errors in production #203

Closed
danizen opened this issue Mar 4, 2022 · 1 comment
Closed

Question - How to handle errors in production #203

danizen opened this issue Mar 4, 2022 · 1 comment

Comments

@danizen
Copy link

danizen commented Mar 4, 2022

Description

I really like the solution of #86, but I think my users will still want to see something in the page if an error occurs in the backend. I am thinking of an implementation I've done with jquery and bootstrap modal where the edit dialog appears - if there is a simple form error, they see the errors in the form and the modal doesn't disappear. Currently, if there is an 500-error, the form just disappears in production and they know something is wrong, but not what. I wish I could do better but I am struggling to get the 20k lines of PL/SQL into Python/Django Models/SQL without losing the performance (pity me).

If I were to rewrite this application with HTMX (which I would love to have time to do), how would I do better and show them something in the UI like "System error occurred"?

Obviously, each call can use try/exception block to catch errors and return them, but maybe there should be a Django setting for an error template in production, or maybe I can handle this entirely with some sort of JavaScript handler - but if I do that, am I missing some of the advantages of HTMX?

@adamchainz
Copy link
Owner

Hi Dan

This is what #43 is intended to cover. I haven't had time to figure out this kind of error handling myself except on a case-by-case basis.

A piece of JS that listens to htmx:responseError and updates the UI accordingly can work well. It isn't that much JS - I would like to document this, but also research in what cases it doesn't work. Using a bit of JS wouldn't lose the advantages of htmx, and you could even use parts of the htmx JS API to update the DOM.

Hope that helps - if I get time I'll try write up an example of this pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants