diff --git a/CHANGES.rst b/CHANGES.rst index 33d650a7..85223166 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on `Keep a Changelog `_, and this project adheres to `Semantic Versioning `_. +Fixed +***** + +- Handle 4xx and 5xx error codes with htmx. :issue:`171` :pr:`181` + [0.0.36] - 2023-12-01 ===================== diff --git a/canaille/static/js/base.js b/canaille/static/js/base.js index 6044b850..ddf785ea 100644 --- a/canaille/static/js/base.js +++ b/canaille/static/js/base.js @@ -12,3 +12,10 @@ document.addEventListener('DOMContentLoaded', function() { document.addEventListener('htmx:load', onDomChanges); + +document.body.addEventListener('htmx:beforeOnLoad', function (evt) { + if (evt.detail.xhr.status >= 400) { + evt.detail.shouldSwap = true; + evt.detail.isError = false; + } +});