Closed wimdeblauwe closed 6 months ago
I would love to be able to use HtmxResponse as the return type for error handlers. This would allow to do something like this:
HtmxResponse
@ExceptionHandler(Exception.class) public HtmxResponse handleError(Exception ex) { return HtmxResponse.builder() .reswap(HtmxReswap.none()) .view(new ModelAndView("fragments/flashmessage :: oob-flashmessage-info", Map.of("message", ex.getMessage()))) .build(); }
The idea is that there is a <div/> on each page that allows to show a general error message via OOB swap.
<div/>
As a workaround, I currently do this:
@ExceptionHandler(Exception.class) public ModelAndView handleError(HttpServletResponse response, Exception ex) { response.setHeader("HX-Reswap", "none"); return new ModelAndView("fragments/flashmessage :: oob-flashmessage-warning", Map.of("message", ex.getMessage())); }
But it would be nicer if we could use HtmxResponse.
I would love to be able to use
HtmxResponse
as the return type for error handlers. This would allow to do something like this:The idea is that there is a
<div/>
on each page that allows to show a general error message via OOB swap.As a workaround, I currently do this:
But it would be nicer if we could use
HtmxResponse
.