Skip to content

fix(core): support method handler on _error, _404 and _500 routes#2955

Merged
marvinhagemeister merged 2 commits intomainfrom
error-method-handler
May 15, 2025
Merged

fix(core): support method handler on _error, _404 and _500 routes#2955
marvinhagemeister merged 2 commits intomainfrom
error-method-handler

Conversation

@marvinhagemeister
Copy link
Collaborator

@marvinhagemeister marvinhagemeister commented May 15, 2025

This PR adds support for using method handlers in _error, _404 and _500 files.

Fixes #2953

marvinhagemeister pushed a commit that referenced this pull request May 15, 2025
Related to #2953.

I found it confusing that there were unsupported route configurations,
that fails silently without any errors or wanings. Though I think it is
a good idea to not throw for this, as that would be worse DX. But
logging a warning if the developer is migrating from Fresh v1, or if the
developer is using code that will not work (e.g. copy pasting a handler
from a route to `_middleware`), I think it's helpful where reasonable to
help guide a bit more.

Does a small refactor first to hopefully improve typing to be more
correct for `InternalRoute.handlers`, then adds warnings for the
following:

- `_middleware` using Object form (`GET`, `POST` handlers) of the
handler format
  - Helps find issues when moving handler from route to middleware
- `_layout` using `handlers`
  - E.g. if developer moves a route to a layout
- ~~`_404`, `_500` or `_error` using Object handler form (`GET`, `POST`
handlers), which is not yet supported (See #2953)~~
  - No longer necessary as it is fixed by #2955
@marvinhagemeister marvinhagemeister merged commit 63cb208 into main May 15, 2025
9 of 10 checks passed
@marvinhagemeister marvinhagemeister deleted the error-method-handler branch May 15, 2025 15:15
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.

[v2.0] Object version of handler not supported for _error, _500 and _404

1 participant