3 ms·
How errors are handled is often pretty specific to each use case. Sometimes it does make sense to send back an HTML fragment with an inline error message, or a
by _heimdall 3y ago
How errors are handled is often pretty specific to each use case.
Sometimes it does make sense to send back an HTML fragment with an inline error message, or a fragment that gets injected as a toast notification. Other times you may want to redirect to an error page with a full page refresh. Depending on the HTTP request method used, you may be able to return an HTTP error response too.
- SahAssar 3y agoAbsolutely. My point is that most or almost all HTMX examples/tutorials/tests show no error handling at all. Sooner or later you need to handle these different errors, and I don't think HTMX has these sort of "non-happy" paths at mind.
- yawaramin 3y agoGo to https://htmx.org/reference/#events https://htmx.org/reference/#events and find in page 'error'. You will see all the different error events that htmx lets you hook into and handle. Don't be fooled by its apparent simplicity. It's very carefully designed.