Expose status and error to layouts, if rendering a generic error page#5532
Expose status and error to layouts, if rendering a generic error page#5532Rich-Harris wants to merge 9 commits intomasterfrom
status and error to layouts, if rendering a generic error page#5532Conversation
🦋 Changeset detectedLatest commit: bc1bd76 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
What about having error pages be separate from the layout tree unless they opt in? I.e. if you want your error page to display using the top-level This would allow the fallback code to only load the top-level Haven't fully thought through the implications of that yet, but it seems like a possible solution here. |
|
Going to close this as it is obsolete in light of #5748. Allowing error pages more control over layout is probably a smart idea, and one we should revisit after the redesign work is complete |
This is a braindump follow-up to #4665, which addresses #4815. As of #4665, the behaviour seen in #4815 will be different — it will render the plaintext error page (because an error status is returned from
__layoutduring the rendering of the__errorpage), which isn't what we want.One possible solution to that is to expose
statusanderrorto__layoutcomponents, so that if a layout does something like this......it's possible to skip that when
loadis called a second time during rendering of the generic error page:This does feel rather messy, and does feel like it hints at a deeper design flaw. It also adds some complexity, since ordinarily layouts don't see these values (we only 'unwind' layout/leaf nodes until we hit an
__errorthat we can render; we don't re-run__layoutand so there's no opportunity to presentstatus/error), there's a distinction between generic and non-generic error pages, which has to be somehow replicated in the client (at present it's easy, because if we initialise the client with an error, only the specified__errorpage gets to see it).An alternative, as suggested in #4815 (comment), is for
__errorpages to be completely separate from the layout tree. I don't love that, since aside from being a significant breaking change it would mean a lot of code duplication between__errorand__layout.Needs some further thought. In the meantime, I'm just going to leave this here.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0