Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass along custom properties added to Error #1821

Merged
merged 2 commits into from
Jul 8, 2021
Merged

Pass along custom properties added to Error #1821

merged 2 commits into from
Jul 8, 2021

Conversation

mohe2015
Copy link
Contributor

@mohe2015 mohe2015 commented Jul 4, 2021

Fixes #1793

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 pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts

@changeset-bot
Copy link

changeset-bot bot commented Jul 4, 2021

🦋 Changeset detected

Latest commit: 6843408

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

@benmccann
Copy link
Member

What attribute are you hoping to pass through exactly? I just passed two more in #1827. Is there anything else that we're still missing? I don't know why this code was originally written the way that it was...

@mohe2015
Copy link
Contributor Author

mohe2015 commented Jul 6, 2021

What attribute are you hoping to pass through exactly? I just passed two more in #1827. Is there anything else that we're still missing? I don't know why this code was originally written the way that it was...

I want to pass custom additional attributes of a subclass of Error through.

@mohe2015
Copy link
Contributor Author

mohe2015 commented Jul 6, 2021

My exact use case is that I want to just throw in a theoretically deep method call in load (not the error one) but this would create a 500 server error. So then I check in the __error load if it's the type of error I'm interested in (not authenticated) and return a 401 instead. I had an attribute with the status code in the error and it didn't get passed along. (The prototype doesn't neither but this seems to be unfixable as it needs to be serialized as far as I understand)

@benmccann benmccann added feature request New feature or request and removed pending clarification labels Jul 8, 2021
@benmccann benmccann changed the title Also serialize additional attributes of the error passed to the error load function. Pass along custom properties added to Error Jul 8, 2021
@benmccann benmccann merged commit 872840a into sveltejs:master Jul 8, 2021
@mohe2015 mohe2015 deleted the error-load-ssr branch July 8, 2021 23:03
sidharthv96 added a commit to sidharthv96/kit that referenced this pull request Jul 11, 2021
* 'master' of github.com:sidharthv96/kit: (1114 commits)
  Version Packages (next) (sveltejs#1858)
  Bump vite-plugin-svelte to 1.0.0-next.12 (sveltejs#1869)
  [fix] preserve user defined config and files on `svelte-kit package` (sveltejs#1735)
  [fix] handle undefined body on endpoint output (sveltejs#1808)
  [fix] copy essentials files from root on packaging (sveltejs#1747)
  [docs] sort config alphabetically (sveltejs#1867)
  add config.kit.package.emitTypes option (sveltejs#1852)
  [fix] add $lib alias to js/tsconfig (sveltejs#1860)
  Pass along custom properties added to Error (sveltejs#1821)
  Version Packages (next) (sveltejs#1840)
  Improve grammar in packages FAQ
  Docs for writing an adapter (sveltejs#1846)
  Additional documentation around pnpx changeset usage
  [feat] expose Vite.js `mode` from `$app/env` (sveltejs#1789)
  Service worker files exclusion support (sveltejs#1645)
  chore: Enable `vite.server.fs.strict` internally by default (sveltejs#1842)
  Test with the latest version of Svelte (sveltejs#1848)
  [docs] don't need to run pnpm install twice
  Improve HN example docs
  [fix] correct `ReadOnlyFormData` generator implementation (sveltejs#1837)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error load function has different parameter prototypes depending on initial load or browser navigation
2 participants