Skip to content

Conversation

@mpscholten
Copy link
Member

Previously, every render/redirect threw a ResponseException which was caught by runAction. Now render/redirect call WAI's respond directly and return IO ResponseReceived.

For early exits (accessDeniedUnless, notFoundWhen, basicAuth), a new earlyReturn helper throws EarlyReturnException after the response is sent.

This should improve performance since exceptions are no longer thrown on every request - only for guard-based early exits.

Relates to #2148

@mpscholten mpscholten force-pushed the response-without-exceptions branch 5 times, most recently from 928975e to ff26324 Compare January 20, 2026 13:03
mpscholten and others added 3 commits January 20, 2026 14:09
Previously, every render/redirect threw a ResponseException which was
caught by runAction. Now render/redirect call WAI's respond directly
and return IO ResponseReceived.

For early exits (accessDeniedUnless, notFoundWhen, basicAuth), a new
earlyReturn helper throws EarlyReturnException after the response is sent.

This should improve performance since exceptions are no longer thrown
on every request - only for guard-based early exits.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove references to ResponseException which is no longer used.
Document earlyReturn for conditional early exits.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create standalone wai-early-return package with earlyReturn function
  and earlyReturnMiddleware
- Add earlyReturnMiddleware to IHP.Server middleware chain
- Remove IHP.Controller.EarlyReturn module (moved to wai-early-return)
- Update AutoRefresh to use middleware for early return handling
- Add wai-early-return to nix overlay and devenv

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mpscholten mpscholten force-pushed the response-without-exceptions branch from ff26324 to f977088 Compare January 20, 2026 13:47
- Add errorHandlerMiddleware that catches all exceptions and displays
  appropriate error pages based on exception type and environment
- Store action type in request vault so error messages can identify
  which action was running when the exception occurred
- Wrap routing exceptions in RouterException newtype to distinguish
  them from action exceptions
- Remove inline exception handling from runAction and frontControllerToWAIApp
- Export writeLog from IHP.Log for direct logger access
- Add wai-early-return to .ghci include paths

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

2 participants