Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Store error in page store (when an error page is triggered) #1498

Merged
merged 12 commits into from Sep 22, 2020

Conversation

ehrencrona
Copy link
Contributor

To fix #948, store the current error in the page store to allow the layout to know whether the current page is an error page (as per suggestion by @Conduitry).

My first PR in this project, so very open to feedback :)

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! And thanks for all your work on the prettier plugin too!

runtime/src/server/middleware/get_page_handler.ts Outdated Show resolved Hide resolved
runtime/src/app/app.ts Outdated Show resolved Hide resolved
@@ -14,7 +14,7 @@ Inside a component, get references to the stores like so:
```

* `preloading` contains a readonly boolean value, indicating whether or not a navigation is pending
* `page` contains a readonly `{ host, path, params, query }` object, identical to that passed to `preload` functions
* `page` contains a readonly `{ host, path, params, query, error, status }` object. The same value is passed to `preload` functions, though `status` is not present at that time and `error` is only set on error pages.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering now if my suggestion to add status maybe wasn't a good one. I hadn't thought through the fact that it wouldn't be available yet in preload. I wonder if it's that useful in this case and maybe that's too much of a caveat to actually add it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wouldn't mind removing it again. I generally don't find it particularly useful and the concept of an http status code doesn't really make sense on the client side. I'll take it out again.

@benmccann
Copy link
Member

Looks like this will need to be rebased since your other PR was merged

@benmccann benmccann mentioned this pull request Sep 22, 2020
@benmccann benmccann merged commit 0523fec into sveltejs:master Sep 22, 2020
featherbear added a commit to featherbear/CTF2-client that referenced this pull request Sep 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make layout know if it's in error page or home page
2 participants