Expose status and error to layouts, if rendering a generic error page
#5532
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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